I wanted to ask one question, but it turned out a few (I hope interrelated).

What do you think should be done if the message received in HTTP 1.1 (rfc2616) with the body declared

Transfer-Encoding: chunked 

instead of the normal end of the next part and the title of the new contains "nonsense"?

I see the following options:

  1. Stop at this place and give it to the handler.

  2. Read further, trying to "recover in the sense of chunks"

  3. Read to end of stream (EOF or timeout)

What are the suggestions?

Also interesting (not yet able to find) chunked and Connection: keep-alive compatible with each other or not? upd { not interested anymore. Compatible. }

And if compatible, then what to do with the connection in case of a similar error?

Upd 1

@razielsd , What do you mean ignore the request? It is clear that it is not necessary to perform it, but what to answer?

And what if this is not a request to me? and the answer to my request?

Generally, close the keep-alive connection? And if not, what to do with the data sent? read them before timeout (how to do it) or how to determine the end of the transfer?

Something I in this RFC will not find algorithms of processing of similar errors.

Upd 2

I will formulate the questions again.

  1. With this error keep-Alive close the connection?
  2. If this error occurred during a request (POST), then give an HTTP / 1.1 response 400 Bad request format ?
  • one
    "The road to Hell is lined up with good intentions" and there is no need to try to restore anything, it will only get worse. If the data is not as expected, an appropriate error should be generated. - Alex Kapustin
  • If familiar with php, see how this is done in Zend_Http (Zend Framework). - razielsd
  • @shurik, you suggest for responce (to my request) to just close the connection, and in such a case for request (the “browser” gave me POST), do you think to send the answer with an error and close it or close it immediately? IMHO to pass an error to him better. Did I understand your idea correctly? - @razielsd, with php and Zend is not familiar. In a nutshell - what do they do there? As far as I understand there a similar situation is possible only for request (request (POST) from the browser). - avp 7:49 pm
  • Everything, I’ve stepped a bit, I understood the essence of the problem :) If you don’t know how to process incoming data, ignore this request. How do you determine that there is nonsense? This is a binary protocol, there can be anything, it is just a coded set of blocks of various sizes. - razielsd
  • > As far as I understand there a similar situation is possible only for request (request (POST) from the browser). No, "Transfer-Encoding: chunked" is usually used for responses. - razielsd

1 answer 1

@avp is a library for accessing external resources.

In the case of "nonsense," if the request to you - ignore the request and give the status of "400 Bad Request", if you get the answer - log and ignore, then understand what the problem is.

  • The question remains what to do if this is a keep-alive connection. Close? IMHO yes. - avp
  • one
    I would close, I do not think, if I began to receive "nonsense," it will turn out to "restore" the connection. - razielsd