You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Cyril SCETBON <cy...@free.fr> on 2007/06/19 23:51:41 UTC

Weird response from both CGI and modperl handlers

Hi people,

I've got some problem with both cgi and modperl.
when I post something to /perl/test.pl which just print header and a 
string I got some strange numbers. The post is done with a php script.

test.pl :

use strict;
use CGI qw/:standard/;

print header;
print("\ncoucou\n");

and below is the response the php script got :

HTTP/1.1 200 OKDate: Tue, 19 Jun 2007 21:39:55 GMTServer: Apache/2.2.3 
(Ubuntu) mod_ssl/2.2.3 OpenSSL/0.9.8c mod_apreq2-20051231/2.6.0 
mod_perl/2.0.2 Perl/v5.8.8Connection: closeTransfer-Encoding: 
chunkedContent-Type: text/html; charset=ISO-8859-18coucou0

It got 8coucou0 instead of coucou.

The issue is that I can't modify the php script which works for other 
customers and this script can't do what it has to because of these two 
more numbers in the response.

for guys who speak php here is the code that post data to /perl/test.pl :

$fd = fsockopen("ssl://".$this->server,443, $errno,$errstr, 60) or 
die("No way to open");
fputs($fd, "POST /perl/test.pl HTTP/1.1\r\n");
fputs ($fd, "Host: ".$this->server."\r\n");
fputs($fd, "Content-type: application/x-www-form-urlencoded\r\n");
fputs ($fd, "Content-length: ".strlen ($fluxsms)."\r\n");
fputs ($fd, "Connection: close\r\n\r\n");
fputs ($fd, $data);
$response = "";
while (!feof ($fd) )
{ $response = $response.fgets($fd, 128); }
fclose($fd);

thanks.

Re: Weird response from both CGI and modperl handlers

Posted by Cyril SCETBON <cy...@free.fr>.

Torsten Foertsch wrote:
> On Wednesday 20 June 2007 09:45, Cyril SCETBON wrote:
>> Are we able to disable the chunk transfer ? To send all in one shot ?
> 
> Add a Content-Length output header and avoid output filters that can change 
> the content length.
Great. It works :-) when using $r->ser_content_length()

thanks.
> 
> Or use HTTP/1.0
> 
> Torsten

Re: Weird response from both CGI and modperl handlers

Posted by Cyril SCETBON <cy...@free.fr>.

Torsten Foertsch wrote:
> On Wednesday 20 June 2007 09:45, Cyril SCETBON wrote:
>> Are we able to disable the chunk transfer ? To send all in one shot ?
> 
> Add a Content-Length output header and avoid output filters that can change 
> the content length.
Great. It works :-) when using $r->ser_content_lenght()

thanks.
> 
> Or use HTTP/1.0
> 
> Torsten

Re: Weird response from both CGI and modperl handlers

Posted by Torsten Foertsch <to...@gmx.net>.
On Wednesday 20 June 2007 09:45, Cyril SCETBON wrote:
> Are we able to disable the chunk transfer ? To send all in one shot ?

Add a Content-Length output header and avoid output filters that can change 
the content length.

Or use HTTP/1.0

Torsten

Re: Weird response from both CGI and modperl handlers

Posted by Cyril SCETBON <cy...@free.fr>.
Are we able to disable the chunk transfer ? To send all in one shot ?



Geoffrey Young wrote:
> 
> Cyril SCETBON wrote:
>> Hi people,
>>
>> I've got some problem with both cgi and modperl.
>> when I post something to /perl/test.pl which just print header and a
>> string I got some strange numbers. The post is done with a php script.
>>
>> test.pl :
>>
>> use strict;
>> use CGI qw/:standard/;
>>
>> print header;
>> print("\ncoucou\n");
>>
>> and below is the response the php script got :
>>
>> HTTP/1.1 200 OKDate: Tue, 19 Jun 2007 21:39:55 GMTServer: Apache/2.2.3
>> (Ubuntu) mod_ssl/2.2.3 OpenSSL/0.9.8c mod_apreq2-20051231/2.6.0
>> mod_perl/2.0.2 Perl/v5.8.8Connection: closeTransfer-Encoding:
>> chunkedContent-Type: text/html; charset=ISO-8859-18coucou0
>>
>> It got 8coucou0 instead of coucou.
>>
> 
> because your php script is not handling the chunked transfer encoding
> properly.
> 
>   http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1
> 
> presumably php has some http-specific libraries for POSTing requests so
> that all this low-level stuff becomes stuff you don't need to worry about.
> 
> --Geoff
> 
> 

Re: Weird response from both CGI and modperl handlers

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Cyril SCETBON wrote:
> Hi people,
> 
> I've got some problem with both cgi and modperl.
> when I post something to /perl/test.pl which just print header and a
> string I got some strange numbers. The post is done with a php script.
> 
> test.pl :
> 
> use strict;
> use CGI qw/:standard/;
> 
> print header;
> print("\ncoucou\n");
> 
> and below is the response the php script got :
> 
> HTTP/1.1 200 OKDate: Tue, 19 Jun 2007 21:39:55 GMTServer: Apache/2.2.3
> (Ubuntu) mod_ssl/2.2.3 OpenSSL/0.9.8c mod_apreq2-20051231/2.6.0
> mod_perl/2.0.2 Perl/v5.8.8Connection: closeTransfer-Encoding:
> chunkedContent-Type: text/html; charset=ISO-8859-18coucou0
> 
> It got 8coucou0 instead of coucou.
> 

because your php script is not handling the chunked transfer encoding
properly.

  http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.6.1

presumably php has some http-specific libraries for POSTing requests so
that all this low-level stuff becomes stuff you don't need to worry about.

--Geoff