tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From horn_...@jpmorgan.com
Subject RE: Multiple GETs on an SSLSocket
Date Tue, 12 Dec 2000 12:52:23 GMT

Chunking is a transfer encoding, introduced in HTTP 1.1.  In 1.0, the
server can set a header, at the start of the stream like:

Content-length: 400\r\n
\r\n
....400 bytes of content ....

Meaning 400 bytes in the body. The problem with this is that the server
needs to know, at the start of the transfer how big the content is going to
be, with static files this is OK, but with dynamic content, it means that
the server would have to generate all content, work out the size of the
buffer, and then send it. In 1.1 to avoid this, a new header:

Transfer-encoding: chunked\r\n
\r\n
200\r\n
... 0x200 bytes of content ...
023\r\n
... 0x023 bytes of content ....
\r\n
extra headers...!\r\n
\r\n

(may have got some of the new lines missing.. it's a while since i did
this)
is used, this allows the content to be streamed in "chunks".

If you want chunked output, try using a HTTP 1.1 GET request.

Ken.





michael.cohen@etl.ericsson.se on 12/12/2000 07:31:53

Please respond to tomcat-user@jakarta.apache.org

To:   tomcat-user@jakarta.apache.org
cc:    (bcc: Ken X Horn)
Subject:  RE: Multiple GETs on an SSLSocket



Hi Ken,

Can you give me a more explicit idea of what you mean
by 'chunking'? Ie the kind of stream/methods to use?

Mike.

> -----Original Message-----
> From: horn_ken@jpmorgan.com [mailto:horn_ken@jpmorgan.com]
> Sent: 12 December 2000 12:22
> To: tomcat-user@jakarta.apache.org
> Subject: RE: Multiple GETs on an SSLSocket
>
>
>
> I wouldn't rely on the ready() to get this right - it will depend on
> whether data has arrived in the underlying stream (native). This will
> probably be system dependent ;o)  The only way I've had this working
> reliably is to rely on content length headers or chunking. Chunking is
> probably best it you can force it.
>
> Ken.
>
>
>
>
>
> michael.cohen@etl.ericsson.se on 12/12/2000 06:27:04
>
> Please respond to tomcat-user@jakarta.apache.org
>
> To:   tomcat-user@jakarta.apache.org
> cc:    (bcc: Ken X Horn)
> Subject:  RE: Multiple GETs on an SSLSocket
>
>
>
> Hi Ken,
> Thanks for your suggestion. Certainly helped but not the whole ten
> yards. I found that by not reading the 'null' at the end of the buffer
> the IO exception is not thrown. I did this using the ready() method of
> BufferedReader. ready() returns false if there is no data in
> the buffer
> to be read. When it returns false I break out of the loop and send the
> second
> GET request to the server. So the second GET doesn't cause a
> IO error. The
> problem
> is that it doesn't cause the second page of html to be downloaded. The
> buffer just
> remians in state 'not ready'.
>
> Right now I'm trying to get it working from the servlet and
> have run into
> an
> unrelated problem.
>
> I'll let you if I find a solution.
>
> Thanks again.
>
> Mike.
> >
> > Have you tried this on a non-SSL connection?
> > A general problem with the IO in java (afaik) is that, if you
> > read from the
> > stream, such that you get a -1 returned, then the stream is
> > effectively
> > closed. You have to reconnect (I haven't tried SSL on this,
> > but a plain
> > socket works like this). If you can control the sending
> > response, ensure
> > either the content-length is specified or the stream is
> > chunked so that you
> > can know when to stop reading -- avoiding getting a -1. YOu
> > can then reuse
> > the socket, without reconnecting.
> >
> > Ken
> >
> >
> >
> >
> >
> > michael.cohen@etl.ericsson.se on 08/12/2000 06:25:10
> >
> > Please respond to tomcat-user@jakarta.apache.org
> >
> > To:   tomcat-user@jakarta.apache.org
> > cc:    (bcc: Ken X Horn)
> > Subject:  Multiple GETs on an SSLSocket
> >
> >
> >
> >
> > Hi,
> >
> > This is more a java/ssl question then tomcat but any ideas on
> > the following
> > will be
> > much appreciated...
> >
> > I'm using a servlet (will be using a servlet at the moment
> > I'm testing in a
> > standalone app.)
> > as a client to connect via https to a server. I've got as far
> > as making the
> > server trusted and performing the ssl handshake and then
> > downloading the
> > first html page.
> >
> > The problem arises when I try to write the second GET request
> > and flush it
> > down
> > the output stream. The flush() method throws an IOException.
> > I'm using the
> > sample code
> > provided with jsse to implement things but that sample code
> > only has one
> > GET request and
> > so works fine. The exception comes with the second GET?
> >
> > Any ideas?
> >
> >
> > Mike C.
> >
> >
> >
> >
> >
> >
> >
> >
>
>
>
>
>
>







Mime
View raw message