• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Streaming response (code) to client

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys I know most of you will say its a bad design and its not possible, but I want to explore the power of HTTP Status codes

I have a client and a server. Theres a loadbalancer in between. For some reason its timeout cannot be increased . I don't want to modify the client.
I am doing a heavy duty processing on the server that exceeds the loadbalancer's timeout.
I was streaming response to the client. After my heavy job is finished i send the final response to client.

Is it possible to somehow alert the client to discard any streamed data sent before the response. Can i send just the response code again. (Any hack?)

My code



Response :

$ curl -i http://localhost:8080/stream
HTTP/1.1 207 Multi-Status
Server: Apache-Coyote/1.1
Content-Type: text/html
Transfer-Encoding: chunked
Date: Mon, 25 Jun 2012 18:34:07 GMT

++++++++++My job's output


I expect

$ curl -i http://localhost:8080/stream
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/html
Transfer-Encoding: chunked
Date: Mon, 25 Jun 2012 18:34:07 GMT

My job's output
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since status codes are sent on the first line of a response, followed by headers, it should be obvious that you can only send a code once.

The subject of handling long running processes within the context of a HTTP server has been covered many times - the consensus is that you should farm long running processes out to a separate thread and provide a mechanism separate request to get the results.

Bill

 
reply
    Bookmark Topic Watch Topic
  • New Topic