Revision 45c76262 src/gr/grnet/pithos/web/client/Helpers.java
b/src/gr/grnet/pithos/web/client/Helpers.java | ||
---|---|---|
1 | 1 |
package gr.grnet.pithos.web.client; |
2 | 2 |
|
3 |
import com.google.gwt.http.client.Header; |
|
4 |
import com.google.gwt.http.client.RequestBuilder; |
|
5 |
import com.google.gwt.http.client.Response; |
|
3 | 6 |
import com.google.gwt.json.client.JSONArray; |
4 | 7 |
import com.google.gwt.json.client.JSONString; |
5 | 8 |
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.Collections; |
|
8 |
import java.util.HashMap; |
|
9 |
import java.util.List; |
|
9 |
import java.util.*; |
|
10 | 10 |
|
11 | 11 |
/** |
12 | 12 |
* Helper methods. |
... | ... | |
64 | 64 |
} |
65 | 65 |
return s.substring(0, index + part.length()); |
66 | 66 |
} |
67 |
|
|
68 |
public static void setHeaders(RequestBuilder builder, Map<String, String> headers) { |
|
69 |
for (String headerName : headers.keySet()) { |
|
70 |
final String headerValue = headers.get(headerName); |
|
71 |
builder.setHeader(headerName, headerValue); |
|
72 |
|
|
73 |
if(Pithos.IsDetailedHTTPLOGEnabled) { |
|
74 |
Pithos.LOG(" ==> ", headerName, ": ", headerValue); |
|
75 |
} |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
public static void LOGResponse(Response response) { |
|
80 |
if(Pithos.IsDetailedHTTPLOGEnabled) { |
|
81 |
try { |
|
82 |
final int statusCode = response.getStatusCode(); |
|
83 |
final String statusText = response.getStatusText(); |
|
84 |
Pithos.LOG(" ", statusCode, " ", statusText); |
|
85 |
final Header[] headers = response.getHeaders(); |
|
86 |
for(Header header : headers) { |
|
87 |
final String name = header.getName(); |
|
88 |
final String value = header.getValue(); |
|
89 |
Pithos.LOG(" <== ", name, ": ", value); |
|
90 |
} |
|
91 |
} |
|
92 |
catch(Exception e) { |
|
93 |
Pithos.LOG("ERROR trying to log response", e); |
|
94 |
} |
|
95 |
} |
|
96 |
} |
|
67 | 97 |
} |
Also available in: Unified diff