You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Ruslan V. Sulakov" <z8...@zr.ru> on 2001/06/04 17:53:59 UTC

HTTP 1.1

Strange numbers appeares, when I use HTTP 1.1 protocol to get response from my mod_perl server.
The test.pl script:
use strict;
use Apache::Request();
my $r = shift;
my $apr = Apache::Request->new($r);
$apr->send_http_header('text/html');
print "1234567";

Now look to  HTTP 1.1. response of this script:
# telnet xx.xx.ru 81
Trying xxx.xxx.xxx.xxx...
Connected to xx.xx.ru.
Escape character is '^]'.
GET /test.pl HTTP/1.1
Accept: */*
Host: xx.xx.ru

HTTP/1.1 200 OK
Date: Mon, 04 Jun 2001 14:49:24 GMT
Server: Apache/1.3.12 (Unix) mod_perl/1.24
Transfer-Encoding: chunked
Content-Type: text/html

1
1234567
0



What does mean number 1 before line "1234567"? And what does mean 0 after all?
Is there a way to cut off the line with number "1" and cut off the line with number "0"?
I need only line "1234567" in response! It is vital for me!

------------
Now look what will be, if I ask HTTP version 1.0:
bsd2# telnet xx.xx.ru 80
Trying 212.188.13.65...
Connected to xx.xx.ru.
Escape character is '^]'.
GET /test.pl HTTP/1.0
Accept: */*
Host: xx.xx.ru

HTTP/1.1 200 OK
Date: Mon, 04 Jun 2001 15:39:16 GMT
Server: Apache/1.3.9 (Unix) mod_perl/1.21 rus/PL28.18
Connection: close
Content-Type: text/html; charset=koi8-r

1234567


Thats all right with HTTP/1.0! No additional lines in output and no Header "Transfer-Encoding: chunked" in response.
------------------------
But I need , it to be all right in case of HTTP/1.1 !

Is there any ideas?

Thanks!
Ruslan


Re: HTTP 1.1

Posted by will trillich <wi...@serensoft.com>.
On Mon, Jun 04, 2001 at 07:53:59PM +0400, Ruslan V. Sulakov wrote:
> Strange numbers appeares, when I use HTTP 1.1 protocol to get response from my mod_perl server.
> The test.pl script:
> use strict;
> use Apache::Request();
> my $r = shift;
> my $apr = Apache::Request->new($r);
> $apr->send_http_header('text/html');
> print "1234567";
> 
> Now look to  HTTP 1.1. response of this script:
> # telnet xx.xx.ru 81
> Trying xxx.xxx.xxx.xxx...
> Connected to xx.xx.ru.
> Escape character is '^]'.
> GET /test.pl HTTP/1.1
> Accept: */*
> Host: xx.xx.ru
> 
> HTTP/1.1 200 OK
> Date: Mon, 04 Jun 2001 14:49:24 GMT
> Server: Apache/1.3.12 (Unix) mod_perl/1.24
> Transfer-Encoding: chunked
> Content-Type: text/html
> 
> 1
> 1234567
> 0

> What does mean number 1 before line "1234567"? And what does mean 0 after all?
> Is there a way to cut off the line with number "1" and cut off the line with number "0"?
> I need only line "1234567" in response! It is vital for me!
> 
> ------------
> Now look what will be, if I ask HTTP version 1.0:
> bsd2# telnet xx.xx.ru 80
> Trying 212.188.13.65...
> Connected to xx.xx.ru.
> Escape character is '^]'.
> GET /test.pl HTTP/1.0
> Accept: */*
> Host: xx.xx.ru
> 
> HTTP/1.1 200 OK
> Date: Mon, 04 Jun 2001 15:39:16 GMT
> Server: Apache/1.3.9 (Unix) mod_perl/1.21 rus/PL28.18
> Connection: close
> Content-Type: text/html; charset=koi8-r
> 
> 1234567
> 
> 
> Thats all right with HTTP/1.0! No additional lines in output and no Header "Transfer-Encoding: chunked" in response.
> ------------------------
> But I need , it to be all right in case of HTTP/1.1 !
> 
> Is there any ideas?

<guess>

here's the key the the answer you're looking for:

	Transfer-Encoding: chunked

for wise browsing software, these numbers are used in
re-constructing the original html from the chunks as they
arrive.

if you're just sending your stuff to an average joe running a
standard web browser, they should all understand this stuff out
of the box. if you're doing something fancy (proxy filter,
maybe?) perhaps you need to check the specs for the HTTP/1.1
protocols and accomodate them. :)

<guess>

-- 
#95: We are waking up and linking to each other. We are watching. But
we are not waiting.  -- www.cluetrain.com

will@serensoft.com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

Re: HTTP 1.1

Posted by Andrew Ho <an...@tellme.com>.
Hello,

RS>Strange numbers appeares, when I use HTTP 1.1 protocol to get response
RS>from my mod_perl server...
RS>
RS>What does mean number 1 before line "1234567"? And what does mean 0
RS>after all? Is there a way to cut off the line with number "1" and cut
RS>off the line with number "0"? I need only line "1234567" in response! It
RS>is vital for me!

The numbers are chunk sizes, which is part of chunked Transfer-Encoding,
part of the HTTP/1.1 specification. You should read this:

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

For dynamically generated content, there is no Content-Length (unless your
script sets one with $r->header_out('Content-Length' => $length) or you
use the associated method in Apache::File). In HTTP/1.0, the server closes
the connection after the script exists, so the missing Content-Length does
not present a problem.

With HTTP/1.1 Keep-Alive, the browser needs to know when to stop reading
the response. The chunked Transfer-Encoding sends chunk sizes, then
chunks, like lots of mini Content-Length fields.

Humbly,

Andrew

----------------------------------------------------------------------
Andrew Ho               http://www.tellme.com/       andrew@tellme.com
Engineer                   info@tellme.com          Voice 650-930-9062
Tellme Networks, Inc.       1-800-555-TELL            Fax 650-930-9101
----------------------------------------------------------------------