-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Bhavesh,

On 2/7/19 19:11, Christopher Schultz wrote:
> The Content-Length of the PUT request says "I'm going to send 128 
> bytes". The server is required to accept exactly 128 bytes, no more
> no less.

There is another option, here, but also requires that the client still
not be broken.

Instead of guessing at the Content-Length and then being wrong about
it, you can use "chunked" encoding.

Chunked encoding is like sending a bunch of small HTTP message-pieces
(I have to be careful about my wording here, since "part" actually
means something in multipart messages), each with its own Content-Length
.

First, you send the request like this:

PUT /foo/bar HTTP/1.1
Host: example.com
Connection: keep-alive
Transfer-Encoding: chunked

Then, you send each chunk with a chunk size (in decimal bytes), a CRLF
pair, then your content, and another CRLF pair. The final chunk has a
length of 0 (zero):

32
[32 bytes of data]
128
[128 bytes of data]
0

(this is the end of the message)

This is great for streaming, because you might not know the size of
the content before you have generated it all. Buffering the whole
message might be impractical.

If the client's problem is that it's not sure what the Content-Length
should be until the message is sent, then you can use chunked encoding
to solve that problem.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlxcyu8ACgkQHPApP6U8
pFhTqg/+Jepl5JnlqViLSh15wyFBYwnBWEiR+d+12B6+21XtJP14yIaw6pnCp0FW
cc/SkLeUl4qywcqRp0f3af8Ub3hb9tE7VB8kMwGiNinUvWp0oDe6kRh8fBBXpHPo
Q/0Sk0OtZS1cHZt2zmzFe5ml8iWn86YPOUVBKuFRCt9yo8630HG/EVD8TZ181FyJ
JbySM+dfkQkhGhow6T59YMR0MxH0FembPnXQ3PQu8NSpmJ+r/7cAbnI0emmNjbNj
xne956Wfb9gIINZI7ch7dmpJcwC4yX7jAibt2f/OFwQ1hrp8XFUPBZpvEjEH2JDp
Y0+wxJ2pAaedqaLwtkob4xo+R6ZGYuyNEn43jM56CqIZV1qfUhVquUTaWkLi6uKy
lwyHTaHxwKQPhdu6y7qQ+aZfoOp6/TLz5Os6OkjTEbixY120jrTPx1FTvq8rSI07
K3V4FvvCQz7cmfv2ya0aUBKnvCT+LytWKDfdLye8TRX0y8QFVC1n+8mGOEdL1vcl
SPa/tCXtmhpJ/LS+n+fQPsqhV+niLc2fFhgUeVZGDv/uFo3BH/8rOCLJLo7N5jg3
GXRoLql0NQX2amdkbzPniY4+mvw/8lRwZeH+4JPfJeBeAIfhY4hIb1taNreTcEN7
sPZAl29SogZuARJG8ch9ZJkV8gfpGjZebfgzJLSMh3g7aIOHA9I=
=ZG7h
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to