LEFT | RIGHT |
1 /* | 1 /* |
2 * HttpUtil.java | 2 * HttpUtil.java |
3 * | 3 * |
4 * Brazil project web application toolkit, | 4 * Brazil project web application toolkit, |
5 * export version: 2.3 | 5 * export version: 2.3 |
6 * Copyright (c) 1999-2004 Sun Microsystems, Inc. | 6 * Copyright (c) 1999-2004 Sun Microsystems, Inc. |
7 * | 7 * |
8 * Sun Public License Notice | 8 * Sun Public License Notice |
9 * | 9 * |
10 * The contents of this file are subject to the Sun Public License Version | 10 * The contents of this file are subject to the Sun Public License Version |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 import java.util.SimpleTimeZone; | 95 import java.util.SimpleTimeZone; |
96 import java.util.StringTokenizer; | 96 import java.util.StringTokenizer; |
97 import sunlabs.brazil.util.regexp.Regexp; | 97 import sunlabs.brazil.util.regexp.Regexp; |
98 | 98 |
99 /** | 99 /** |
100 * The <code>HttpUtil</code> class contains methods for performing simple | 100 * The <code>HttpUtil</code> class contains methods for performing simple |
101 * HTTP operations. | 101 * HTTP operations. |
102 * | 102 * |
103 * @author Colin Stevens (colin.stevens@sun.com) | 103 * @author Colin Stevens (colin.stevens@sun.com) |
104 * @version 2.3 | 104 * @version 2.3 |
105 * | |
106 */ | 105 */ |
107 public class HttpUtil | 106 public class HttpUtil |
108 { | 107 { |
109 private HttpUtil() {} | 108 private HttpUtil() {} |
110 | 109 |
111 /** | 110 /** |
112 * Which ascii characters may be sent in HTML without escaping | 111 * Which ascii characters may be sent in HTML without escaping |
113 */ | 112 */ |
114 private static String[] htmlMap = new String[256]; | 113 private static String[] htmlMap = new String[256]; |
115 | 114 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 * | 288 * |
290 * @param time | 289 * @param time |
291 * The date to format (current time in msec). | 290 * The date to format (current time in msec). |
292 * | 291 * |
293 * @return HTTP date string representing the given time. | 292 * @return HTTP date string representing the given time. |
294 */ | 293 */ |
295 public static String | 294 public static String |
296 formatTime(long time) | 295 formatTime(long time) |
297 { | 296 { |
298 String date = dateFormat.format(new Date(time)); | 297 String date = dateFormat.format(new Date(time)); |
299 if (date.length() >= 29) | 298 int plus = date.indexOf('+'); |
300 date = date.substring(0, 29); | 299 if (plus > 0) |
| 300 date = date.substring(0, plus); |
301 return date; | 301 return date; |
302 } | 302 } |
303 | 303 |
304 /** | 304 /** |
305 * Convert a last-modified date in "standard" format | 305 * Convert a last-modified date in "standard" format |
306 * into a time stamp. This "inverses" formatTime. | 306 * into a time stamp. This "inverses" formatTime. |
307 * | 307 * |
308 * @param time | 308 * @param time |
309 * A correctly formatted HTTP date string. | 309 * A correctly formatted HTTP date string. |
310 * @return milliseconds since the epoch, or 0 if the conversion | 310 * @return milliseconds since the epoch, or 0 if the conversion |
311 * failed. | 311 * failed. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 case 500: return "Server Error"; | 449 case 500: return "Server Error"; |
450 case 501: return "Not Implemented"; | 450 case 501: return "Not Implemented"; |
451 case 502: return "Bad Gateway"; | 451 case 502: return "Bad Gateway"; |
452 case 503: return "Service Unavailable"; | 452 case 503: return "Service Unavailable"; |
453 case 504: return "Gateway Time-out"; | 453 case 504: return "Gateway Time-out"; |
454 case 505: return "HTTP Version not supported"; | 454 case 505: return "HTTP Version not supported"; |
455 default: return "Error"; | 455 default: return "Error"; |
456 } | 456 } |
457 } | 457 } |
458 } | 458 } |
LEFT | RIGHT |