You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/05/25 17:50:47 UTC
svn commit: r778442 - in /incubator/pivot/trunk/web:
src/pivot/web/Query.java test/pivot/web/test/WebQueryTestClient.java
Author: gbrown
Date: Mon May 25 15:50:46 2009
New Revision: 778442
URL: http://svn.apache.org/viewvc?rev=778442&view=rev
Log:
Allow non-success query responses to include headers; use addRequestProperty() to apppend request headers to request.
Modified:
incubator/pivot/trunk/web/src/pivot/web/Query.java
incubator/pivot/trunk/web/test/pivot/web/test/WebQueryTestClient.java
Modified: incubator/pivot/trunk/web/src/pivot/web/Query.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/web/src/pivot/web/Query.java?rev=778442&r1=778441&r2=778442&view=diff
==============================================================================
--- incubator/pivot/trunk/web/src/pivot/web/Query.java (original)
+++ incubator/pivot/trunk/web/src/pivot/web/Query.java Mon May 25 15:50:46 2009
@@ -266,8 +266,7 @@
locationContext = new URL(secure ? HTTPS_PROTOCOL : HTTP_PROTOCOL,
hostname, port, path);
} catch (MalformedURLException exception) {
- throw new IllegalArgumentException(
- "Unable to construct context URL.", exception);
+ throw new IllegalArgumentException("Unable to construct context URL.", exception);
}
}
@@ -461,7 +460,7 @@
connection.setUseCaches(false);
if (connection instanceof HttpsURLConnection
- && hostnameVerifier != null) {
+ && hostnameVerifier != null) {
HttpsURLConnection httpsConnection = (HttpsURLConnection) connection;
httpsConnection.setHostnameVerifier(hostnameVerifier);
}
@@ -472,14 +471,13 @@
}
for (String key : requestHeaders) {
- StringBuffer buffer = new StringBuffer();
- for (int index = 0; index < requestHeaders.getLength(key); index++) {
- if (index > 0) {
- buffer.append(",");
+ for (int i = 0, n = requestHeaders.getLength(key); i < n; i++) {
+ if (i == 0) {
+ connection.setRequestProperty(key, requestHeaders.get(key, i));
+ } else {
+ connection.addRequestProperty(key, requestHeaders.get(key, i));
}
- buffer.append(requestHeaders.get(key, index));
}
- connection.setRequestProperty(key, buffer.toString());
}
// Set the input/output state
@@ -510,12 +508,6 @@
status = connection.getResponseCode();
message = connection.getResponseMessage();
- // If the response was anything other than 2xx, throw an exception
- int statusPrefix = status / 100;
- if (statusPrefix != 2) {
- throw new QueryException(status, message);
- }
-
// Record the content length
bytesExpected = connection.getContentLength();
@@ -526,6 +518,12 @@
responseHeaders.add(key, connection.getHeaderField(i));
}
+ // If the response was anything other than 2xx, throw an exception
+ int statusPrefix = status / 100;
+ if (statusPrefix != 2) {
+ throw new QueryException(status, message);
+ }
+
// Read the response body
if (method == Method.GET) {
InputStream inputStream = null;
Modified: incubator/pivot/trunk/web/test/pivot/web/test/WebQueryTestClient.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/web/test/pivot/web/test/WebQueryTestClient.java?rev=778442&r1=778441&r2=778442&view=diff
==============================================================================
--- incubator/pivot/trunk/web/test/pivot/web/test/WebQueryTestClient.java (original)
+++ incubator/pivot/trunk/web/test/pivot/web/test/WebQueryTestClient.java Mon May 25 15:50:46 2009
@@ -55,7 +55,7 @@
System.out.println("GET result: "
+ "username: " + result.get("username") + ", "
+ "pathInfo: " + result.get("pathInfo") + ", "
- + "queryString: " + result.get("queryString")
+ + "queryString: " + result.get("queryString") + ", "
+ "status: " + getQuery.getStatus());
}