Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: src/sunlabs/brazil/util/http/HttpUtil.java

Issue 8961044: android: brazil StringIndexOutOfBoundsException fix (Closed)
Left Patch Set: Created Nov. 27, 2012, 11:38 a.m.
Right Patch Set: android: brazil StringIndexOutOfBoundsException fix Created Nov. 27, 2012, 1:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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
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;
Andrey Novikov 2012/11/27 13:03:20 I will fix it before commit in vi.
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
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 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld