The incorrect content length problem with Apache, how to stop waiting for data, and send a reply in

S

samkipers445r

Hello

Maybe someone who knows apache internals can help on this issue.

We created an http client application, and a server CGI script on perl
to exchange data between the application which is spread among many
users and our server. Unfortunately the client application had a bug
with https POST method when it sent less data than specified in content
length header. It happens on a certain combination of input data
entered by end user. As the result the Apache server waits for the
missing data because of incorrect content length sent by the client,
and we never have a chance to send a reply back to the client
application. The client application simply closes the connection after
one minute timeout period.

Is there any way to force Apache to cancel the wait on receiving
missing data in Post method and switch it to sending data to reply back
to the client application from CGI script?

We tried writing to stdout and/or closing stdin, but it doesn't help,
it seems Apache keeps on hanging, and doesn't want to send anything
while waiting for missing data because of incorrect content length.

Thanks,
Sam Kipers
 
J

Juha Laiho

(e-mail address removed) said:
We created an http client application, and a server CGI script on perl
to exchange data between the application which is spread among many
users and our server. Unfortunately the client application had a bug
with https POST method when it sent less data than specified in content
length header.

Well, wouldn't it be better to fix the client application (as you said,
you created it, so you should still be able to change it), than to leave
the client buggy and create a separate workaround?
Is there any way to force Apache to cancel the wait on receiving
missing data in Post method and switch it to sending data to reply back
to the client application from CGI script?

This might be possible with a nph-script (no-parse-headers), which
pretty much will make apache into a raw data pipe - instead of its
normal mode of operation, where it makes at least some sanity checks
to the data - in order to partially protect the server application.
So, with a nph-script, the server-side script has the full responsibility
to handle anything that might come down the pipe (ok, it is required
that the start of request is correct enough HTTP that Apache knows
to fire the script, but after that, all is up to your script. Still,
fixing the client end would be much better.
 
S

samkipers445r

Hello Juha,

thanks for the reply.

The bug in the client has been fixed already. We cannot update the
client among our clients quickly. Usually it takes 2-3 months. Thus the
problem still persists. The server is overloaded with idle script
processes.

we have renamed the script to nph-xxx.pl and the problem still
persists. yes, in case of nph scripts, we should send all headers back
to client, for example "HTTP/1.0 302 Moved\r\n" and apache passes it to
the client without modification, but it doesn't fix the problem. apache
still waits for missing data, and it seems that it parses the content
length header in the query anyway.

Is there a way to fix the problem programmatically with CGI? Somehow we
need to tell Apache to stop waiting for data and send a required reply
to the client.

I feel that customizing/patching Apache for this particular problem is
not a good decision.

Any suggestions?

Thanks,
Sam Kipers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top