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

Side by Side Diff: src/sunlabs/brazil/util/http/HttpUtil.java

Issue 8961044: android: brazil StringIndexOutOfBoundsException fix (Closed)
Patch Set: Created Nov. 27, 2012, 11:38 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 * 1.0 (the "License"). You may not use this file except in compliance with 11 * 1.0 (the "License"). You may not use this file except in compliance with
12 * the License. A copy of the License is included as the file "license.terms", 12 * the License. A copy of the License is included as the file "license.terms",
13 * and also available at http://www.sun.com/ 13 * and also available at http://www.sun.com/
14 * 14 *
15 * The Original Code is from: 15 * The Original Code is from:
16 * Brazil project web application toolkit release 2.3. 16 * Brazil project web application toolkit release 2.3.
17 * The Initial Developer of the Original Code is: cstevens. 17 * The Initial Developer of the Original Code is: cstevens.
18 * Portions created by cstevens are Copyright (C) Sun Microsystems, Inc. 18 * Portions created by cstevens are Copyright (C) Sun Microsystems, Inc.
19 * All Rights Reserved. 19 * All Rights Reserved.
20 * 20 *
21 * Contributor(s): cstevens, guym, suhler. 21 * Contributor(s): cstevens, guym, suhler.
22 * 22 *
23 * Version: 2.3 23 * Version: 2.3
24 * Created by cstevens on 99/09/15 24 * Created by cstevens on 99/09/15
25 * Last modified by suhler on 04/11/30 15:19:46 25 * Last modified by suhler on 04/11/30 15:19:46
26 * 26 *
27 * Version Histories: 27 * Version Histories:
28 * 28 *
29 * unversioned 12/11/27-15:37:00 (Andrey Novikov)
30 * fixed StringIndexOutOfBoundsException in formatTime(long time)
31 *
29 * 2.3 04/11/30-15:19:46 (suhler) 32 * 2.3 04/11/30-15:19:46 (suhler)
30 * fixed sccs version string 33 * fixed sccs version string
31 * 34 *
32 * 2.2 03/08/01-16:17:39 (suhler) 35 * 2.2 03/08/01-16:17:39 (suhler)
33 * fixes for javadoc 36 * fixes for javadoc
34 * 37 *
35 * 2.1 02/10/01-16:37:05 (suhler) 38 * 2.1 02/10/01-16:37:05 (suhler)
36 * version change 39 * version change
37 * 40 *
38 * 1.14 02/07/29-14:57:34 (suhler) 41 * 1.14 02/07/29-14:57:34 (suhler)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 import java.util.SimpleTimeZone; 95 import java.util.SimpleTimeZone;
93 import java.util.StringTokenizer; 96 import java.util.StringTokenizer;
94 import sunlabs.brazil.util.regexp.Regexp; 97 import sunlabs.brazil.util.regexp.Regexp;
95 98
96 /** 99 /**
97 * The <code>HttpUtil</code> class contains methods for performing simple 100 * The <code>HttpUtil</code> class contains methods for performing simple
98 * HTTP operations. 101 * HTTP operations.
99 * 102 *
100 * @author Colin Stevens (colin.stevens@sun.com) 103 * @author Colin Stevens (colin.stevens@sun.com)
101 * @version 2.3 104 * @version 2.3
105 *
102 */ 106 */
103 public class HttpUtil 107 public class HttpUtil
104 { 108 {
105 private HttpUtil() {} 109 private HttpUtil() {}
106 110
107 /** 111 /**
108 * Which ascii characters may be sent in HTML without escaping 112 * Which ascii characters may be sent in HTML without escaping
109 */ 113 */
110 private static String[] htmlMap = new String[256]; 114 private static String[] htmlMap = new String[256];
111 115
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 * Returns a string containing an HTTP-formatted date. 288 * Returns a string containing an HTTP-formatted date.
285 * 289 *
286 * @param time 290 * @param time
287 * The date to format (current time in msec). 291 * The date to format (current time in msec).
288 * 292 *
289 * @return HTTP date string representing the given time. 293 * @return HTTP date string representing the given time.
290 */ 294 */
291 public static String 295 public static String
292 formatTime(long time) 296 formatTime(long time)
293 { 297 {
294 » return dateFormat.format(new Date(time)).substring(0, 29); 298 String date = dateFormat.format(new Date(time));
299 if (date.length() >= 29)
300 date = date.substring(0, 29);
301 » return date;
Andrey Novikov 2012/11/27 13:03:20 I will fix it before commit in vi.
295 } 302 }
296 303
297 /** 304 /**
298 * Convert a last-modified date in "standard" format 305 * Convert a last-modified date in "standard" format
299 * into a time stamp. This "inverses" formatTime. 306 * into a time stamp. This "inverses" formatTime.
300 * 307 *
301 * @param time 308 * @param time
302 * A correctly formatted HTTP date string. 309 * A correctly formatted HTTP date string.
303 * @return milliseconds since the epoch, or 0 if the conversion 310 * @return milliseconds since the epoch, or 0 if the conversion
304 * failed. 311 * failed.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 case 500: return "Server Error"; 449 case 500: return "Server Error";
443 case 501: return "Not Implemented"; 450 case 501: return "Not Implemented";
444 case 502: return "Bad Gateway"; 451 case 502: return "Bad Gateway";
445 case 503: return "Service Unavailable"; 452 case 503: return "Service Unavailable";
446 case 504: return "Gateway Time-out"; 453 case 504: return "Gateway Time-out";
447 case 505: return "HTTP Version not supported"; 454 case 505: return "HTTP Version not supported";
448 default: return "Error"; 455 default: return "Error";
449 } 456 }
450 } 457 }
451 } 458 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld