You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to hava async HTTP call within a suspended GET request. In this code I dynamically set resumeOnBroadcast based on the client's HTTP request header. However, I found out in the HTTP response two "Content-Type: application/json" are returned. Is that a bug? (I'm using 1.1.0.RC4)
This is a code snippet of what I'm trying to do
@GET@Produces(MediaType.APPLICATION_JSON)
publicSuspendResponse<String> subscribe(@ContextHttpHeadersheaders) {
// Check if the client want to keep the connection open for HTTP// streamingbooleanresumeOnBroadcast = false;
if (headers.getRequestHeader("Connection") != null
&& headers.getRequestHeader("Connection")
.contains("keep-alive")) {
resumeOnBroadcast = false;
} else {
resumeOnBroadcast = true;
}
returnnewSuspendResponse.SuspendResponseBuilder<String>()
.broadcaster(topic).resumeOnBroadcast(resumeOnBroadcast)
.outputComments(true)
.addListener(newWebSocketEventListener() {
publicvoidonBroadcast(AtmosphereResourceEventarg0) {
}
publicvoidonDisconnect(AtmosphereResourceEventarg0) {
}
publicvoidonPreSuspend(AtmosphereResourceEventarg0) {
}
publicvoidonResume(AtmosphereResourceEventarg0) {
}
publicvoidonSuspend(AtmosphereResourceEventarg0) {
// Enabling this line only will create the same problem// topic.broadcast("{\"message\": \"broadcasted message\"}");AsyncHttpClientasyncHttpClient = newAsyncHttpClient();
try {
Future<Response> f = asyncHttpClient.prepareGet(
"http://www.ning.com/").execute();
f.get();
topic.broadcast("{\"message\": \"broadcasted message\"}");
} catch (IOExceptione) {
e.printStackTrace();
} catch (InterruptedExceptione) {
e.printStackTrace();
} catch (ExecutionExceptione) {
e.printStackTrace();
}
asyncHttpClient.close();
}
publicvoidonThrowable(AtmosphereResourceEventarg0) {
}
publicvoidonClose(WebSocketEventarg0) {
}
publicvoidonConnect(WebSocketEventarg0) {
}
publicvoidonControl(WebSocketEventarg0) {
}
publicvoidonDisconnect(WebSocketEventarg0) {
}
publicvoidonHandshake(WebSocketEventarg0) {
}
publicvoidonMessage(WebSocketEventarg0) {
}
}).build();
}
And here how I tested it using cURL:
curl -H "Connection: close" -v -N -XGET "http://localhost:8080/pubsub/topic1"* About to connect() to localhost port 8080 (#0)* Trying ::1... connected
* Connected to localhost (::1) port 8080 (#0)> GET /pubsub/topic1 HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8x zlib/1.2.5
> Host: localhost:8080
> Accept: */*> Connection: close
>< HTTP/1.1 200 OK
< X-Atmosphere-tracking-id: f2f78148-49ae-4b08-8a9d-22aee3797eee
< Expires: -1
< Cache-Control: no-store, no-cache, must-revalidate
< Pragma: no-cache
< Access-Control-Allow-Origin: *< Access-Control-Allow-Credentials: true< Content-Type: application/json
< Content-Type: application/json
< Connection: close
< Server: Jetty(8.1.11.v20130520)
<
{"message": "broadcasted message"}* Closing connection #0
The text was updated successfully, but these errors were encountered:
I'm trying to hava async HTTP call within a suspended GET request. In this code I dynamically set resumeOnBroadcast based on the client's HTTP request header. However, I found out in the HTTP response two "Content-Type: application/json" are returned. Is that a bug? (I'm using 1.1.0.RC4)
This is a code snippet of what I'm trying to do
And here how I tested it using cURL:
The text was updated successfully, but these errors were encountered: