You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Simon Dansereau <Si...@USherbrooke.ca> on 2007/02/05 20:07:37 UTC

Async HTTP

Hi,

I would like to know how can I use http-core to send two responses to a client
without closing the connection. I guess I will have to use httpcore-nio. I
tried to modify AsyncHttpServer.java example but I didn't know where to start.

As soon as I get a request, I would like to send a "server is processing your
request" response. The page would contain a little animation to make sure user
don't think the application is down.

Then, after processing is completed (10-20 seconds), I would like to send the
"result" response.

Can someone help me?

Simon

---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


Re: Async HTTP

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2007-02-05 at 14:07 -0500, Simon Dansereau wrote:
> Hi,
> 
> I would like to know how can I use http-core to send two responses to a client
> without closing the connection. I guess I will have to use httpcore-nio. I
> tried to modify AsyncHttpServer.java example but I didn't know where to start.
> 
> As soon as I get a request, I would like to send a "server is processing your
> request" response. The page would contain a little animation to make sure user
> don't think the application is down.
> 
> Then, after processing is completed (10-20 seconds), I would like to send the
> "result" response.
> 

Simon,

Theoretically this is possible but you would be really abusing the HTTP
protocol that way. HTTP is a request / response oriented protocol, and
as far as I can tell one HTTP request always implies just one HTTP non
1xx response. You can use the 102 - 199 status code range to send an
intermediate response to the client, but I would strongly recommend you
re-assess your architecture options before you go that route.

Oleg 



> Can someone help me?
> 
> Simon
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


Re: Async HTTP

Posted by Roland Weber <ht...@dubioso.net>.
Hello Simon,

in order to send two actual responses to the client, the client
MUST send two requests to the server. This can be done
without closing the connection, which is called keep-alive.

While there are theoretical options to send an intermediate
response, these are typically not supported by server-side
APIs such as the Servlet API. Nor are they understood by the
typical HTTP clients, such as browsers. Nor would you be able
to send any _content_ with the intermediate response, such
as a "please wait" page with an animation. It would be a custom
extension of the HTTP protocol and would bring you all kinds
of problems with proxies, browsers, and servers.

The appropriate way to achieve your purpose is to start a
worker thread on the first request, then have the client send
a new request and block that one until the worker has computed
the result.

hope that helps,
  Roland


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org