- Timestamp:
- 2010-09-03T23:12:56+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmApiException.java
r3083 r3511 61 61 sb.append("ResponseCode=") 62 62 .append(responseCode); 63 if (errorHeader != null && errorBody != null && !errorBody.trim().equals("")) { 64 sb.append(", Error Header=<") 65 .append(tr(errorHeader)) 66 .append(">"); 67 } 68 if (errorBody != null && !errorBody.trim().equals("")) { 69 errorBody = errorBody.trim(); 70 if(!errorBody.equals(errorHeader)) { 71 sb.append(", Error Body=<") 72 .append(tr(errorBody)) 63 String eh = ""; 64 try 65 { 66 if(errorHeader != null) 67 eh = tr(errorHeader.trim()); 68 if (!eh.isEmpty()) { 69 sb.append(", Error Header=<") 70 .append(eh) 73 71 .append(">"); 74 72 } 73 } 74 catch (Exception e) { 75 } 76 try 77 { 78 String eb = errorBody != null ? tr(errorBody.trim()) : ""; 79 if (!eb.isEmpty() && !eb.equals(eh)) { 80 sb.append(", Error Body=<") 81 .append(eb) 82 .append(">"); 83 } 84 } 85 catch (Exception e) { 75 86 } 76 87 return sb.toString(); -
trunk/src/org/openstreetmap/josm/io/OsmServerReader.java
r3021 r3511 5 5 6 6 import java.io.BufferedReader; 7 import java.io.IOException; 7 8 import java.io.InputStream; 8 9 import java.io.InputStreamReader; … … 94 95 throw new OsmTransferCancelledException(); 95 96 97 String encoding = activeConnection.getContentEncoding(); 96 98 if (activeConnection.getResponseCode() != HttpURLConnection.HTTP_OK) { 97 99 String errorHeader = activeConnection.getHeaderField("Error"); 98 InputStream i = null;99 i = activeConnection.getErrorStream();100 100 StringBuilder errorBody = new StringBuilder(); 101 if (i != null) { 102 BufferedReader in = new BufferedReader(new InputStreamReader(i)); 103 String s; 104 while((s = in.readLine()) != null) { 105 errorBody.append(s); 106 errorBody.append("\n"); 101 try 102 { 103 InputStream i = FixEncoding(activeConnection.getErrorStream(), encoding); 104 if (i != null) { 105 BufferedReader in = new BufferedReader(new InputStreamReader(i)); 106 String s; 107 while((s = in.readLine()) != null) { 108 errorBody.append(s); 109 errorBody.append("\n"); 110 } 107 111 } 112 } 113 catch(Exception e) { 114 errorBody.append(tr("Reading error text failed.")); 108 115 } 109 116 … … 111 118 } 112 119 113 String encoding = activeConnection.getContentEncoding(); 114 InputStream inputStream = new ProgressInputStream(activeConnection, progressMonitor); 115 if (encoding != null && encoding.equalsIgnoreCase("gzip")) { 116 inputStream = new GZIPInputStream(inputStream); 117 } 118 else if (encoding != null && encoding.equalsIgnoreCase("deflate")) { 119 inputStream = new InflaterInputStream(inputStream, new Inflater(true)); 120 } 121 return inputStream; 120 return FixEncoding(new ProgressInputStream(activeConnection, progressMonitor), encoding); 122 121 } catch(Exception e) { 123 122 if (e instanceof OsmTransferException) … … 130 129 progressMonitor.invalidate(); 131 130 } 131 } 132 133 private InputStream FixEncoding(InputStream stream, String encoding) throws IOException 134 { 135 if (encoding != null && encoding.equalsIgnoreCase("gzip")) { 136 stream = new GZIPInputStream(stream); 137 } 138 else if (encoding != null && encoding.equalsIgnoreCase("deflate")) { 139 stream = new InflaterInputStream(stream, new Inflater(true)); 140 } 141 return stream; 132 142 } 133 143
Note:
See TracChangeset
for help on using the changeset viewer.