You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Jason Fister <ja...@gmail.com> on 2008/09/17 20:49:20 UTC
'Expect' HTTP Header
Hello folks,
According to HTTP 1.1 spec, if a client sends a Expect: 100-continue header
with a request, the server can inspect the header and reply with a HTTP
status 100 Continue if its ready to accept the data. The client after
receiving the 100 request will send the request body. The server is also
allowed to send a final http status msg and close the connection after
inspecting the headers if it doesn't want to accept the request body.
I am trying to implement this in my apache module but am a little confused
as to how to do this. Here is a section of the code:
static int my_handler(request_rec* req)
{
.....
.....
.....
bool sta = ShouldSrvrRespondWith100(req);
if (tru==sta)
{
req->status = HTTP_CONTINUE;
return OK;
}
else
{
ProcessRequest(req);
}
}
The function 'ShouldSrvrRespondWith100' is defined as
bool ShouldSrvrRespondWith100(request_rec* req)
{
if((HTTP ver is 1.1) && ('Expect' HTTP header is set))
{
return true;
}
else
{
return false;
}
}
Am I doing this correctly? What is don't understand is I want to resume
execution of the code from where I left off before I sent the 100 http
status to the client - how do I achieve that?
in the request_rec structure, there is a field called 'expecting_100' should
I be checking this value in the request to see if this particular request is
in response to a 100 continue from the server?
Thanks!
Jason
Re: 'Expect' HTTP Header
Posted by Jason Fister <ja...@gmail.com>.
Thanks for your response.
>
>
> AIUI: In your handler, you ask the input filters for the body. If the
> client is expecting 100-continue, the HTTP input filter takes care of
> responding to it.
>
I use
ap_setup_client_block
ap_should_client_block(req)
ap_get_client_block
to get the request body.
But before I get to that stage, I want to process the HTTP headers to see if
I want to continue accepting the rest of the request. If yes, I want to
respond with a 100 Continue status. Will apache automatically send 100
Continue response to the client as soon as I set req->status =
HTTP_CONTINUE, wait and resume processing when the client starts sending the
rest of the request?
>
> see ap_http_filter() in modules/http/http_filters.c
>
> You could probably short-circuit the regular processing (but not in an
> API friendly way).
>
I will take a look at the file that you have mentioned.
Thanks again.
>
>
> --
> Eric Covener
> covener@gmail.com
>
Re: 'Expect' HTTP Header
Posted by Eric Covener <co...@gmail.com>.
On Thu, Sep 18, 2008 at 3:35 PM, Jason Fister <ja...@gmail.com> wrote:
> Can anyone point me in the right direction? I have searched on the web
> extensively but I did not find anything helpful.
AIUI: In your handler, you ask the input filters for the body. If the
client is expecting 100-continue, the HTTP input filter takes care of
responding to it.
see ap_http_filter() in modules/http/http_filters.c
You could probably short-circuit the regular processing (but not in an
API friendly way).
--
Eric Covener
covener@gmail.com
Re: 'Expect' HTTP Header
Posted by Jason Fister <ja...@gmail.com>.
Can anyone point me in the right direction? I have searched on the web
extensively but I did not find anything helpful.
On Wed, Sep 17, 2008 at 2:49 PM, Jason Fister <ja...@gmail.com> wrote:
> Hello folks,
> According to HTTP 1.1 spec, if a client sends a Expect: 100-continue header
> with a request, the server can inspect the header and reply with a HTTP
> status 100 Continue if its ready to accept the data. The client after
> receiving the 100 request will send the request body. The server is also
> allowed to send a final http status msg and close the connection after
> inspecting the headers if it doesn't want to accept the request body.
>
> I am trying to implement this in my apache module but am a little confused
> as to how to do this. Here is a section of the code:
>
> static int my_handler(request_rec* req)
> {
> .....
> .....
> .....
> bool sta = ShouldSrvrRespondWith100(req);
> if (tru==sta)
> {
> req->status = HTTP_CONTINUE;
> return OK;
> }
> else
> {
> ProcessRequest(req);
> }
> }
>
> The function 'ShouldSrvrRespondWith100' is defined as
>
> bool ShouldSrvrRespondWith100(request_rec* req)
> {
> if((HTTP ver is 1.1) && ('Expect' HTTP header is set))
> {
> return true;
> }
> else
> {
> return false;
> }
> }
>
>
> Am I doing this correctly? What is don't understand is I want to resume
> execution of the code from where I left off before I sent the 100 http
> status to the client - how do I achieve that?
>
> in the request_rec structure, there is a field called 'expecting_100'
> should I be checking this value in the request to see if this particular
> request is in response to a 100 continue from the server?
>
> Thanks!
> Jason
>