Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

How to respond to an Expect:100-Continue Header

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am experimenting with the Expect:100-Continue Header and i am facing  an 5 second delay between sending the http body to the server and receiving the 100 Continue response code from the server.

Here is the client code



I am not interested in parsing the http data sent from the client but only in responding to it. In this case i just print the data received . From the  RFC Docs i have learnt that this is a 2 step process

1. The client sends headers and the server is supposed to respond with an 100 Continue code if the server has no problems with them. In this case i skip all checking and directly send 100 Continue

2. After the client sends the request body the server is supposed to respond with an final status code [200 OK or any other] to indicate end of the body. I send 200 response code

Here is the server



The problem is that there is an 5 second delay between step 1 and 2. If i respond with any other status code besides 100 for example


Then on the client side an exception is thrown immediately saying server rejected the request which makes perfect sense but when I send the 100 response code the server receives the body after 5 seconds.

Here is the output on the server side



Here is the output on the client



The same thing happens when i use chunk Transfer mode as well . Between each chunk there is an 5 second delay

Here is the Question from which i got the code from and modified it. The User has marked the answer as accepted but didn't give any code explanation as to how he solved the problem. If i were to ask the question there now it would get marked as duplicate.

How do i properly handle an Expect : 100 header in this case?
 
Renard Desmon
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So i had dropped an comment on the Asker of the Question asking for his final solution and it turns out that significant
changes were made actually in the client side more than in the server side.

Multiple OutputStream retrivals had to be changed from this



To this


This fixed everything
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic