You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Roland Hänel (Created JIRA)" <ji...@apache.org> on 2012/03/12 17:51:38 UTC

[jira] [Created] (HTTPCORE-296) IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)

IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)
-----------------------------------------------------------------------------

                 Key: HTTPCORE-296
                 URL: https://issues.apache.org/jira/browse/HTTPCORE-296
             Project: HttpComponents HttpCore
          Issue Type: Bug
          Components: HttpCore NIO
    Affects Versions: 4.2-alpha2
            Reporter: Roland Hänel


If a client submits a POST with Content-Length 0, the HttpCore framework will fire the onContentReceived(...) method of the HttpAsyncRequestConsumer once. However, the decoder (passed as an argument to onContentReceived()) will never enter the "completed" state, because no bytes will actually be received from the client. However, reaching the "completed" stage of the decoder is an requirement for the HttpAsyncServiceHandler to finally process the request (i.e., call the handle(...) method).

This leads to the (incorrect) behavior that it is impossible to handle a POST request with Content-Length 0 in HttpCore NIO.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Commented] (HTTPCORE-296) IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)

Posted by "Roland Hänel (Commented JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13227697#comment-13227697 ] 

Roland Hänel commented on HTTPCORE-296:
---------------------------------------

Additional information / correction:

This does *not* happen if a Content-Length: 0 header is included with the request. If the request has a CL: 0 header, everything is fine.

The problem happens if the request (POST) does not include any Content-Length: header. This seems to be the default implementation in the Python 2.7 (sic!) client when sending a POST request with zero bytes of request data.

In this case (no CL header at all in the request), HttpCore does not select the LengthDelimitedDecoder but the IdentityDecoder, which in turn never reaches the complete state. 

The solution might be to select the the LengthDelimitedDecoder with a target len of 0 in this case.
                
> IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)
> -----------------------------------------------------------------------------
>
>                 Key: HTTPCORE-296
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-296
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.2-alpha2
>            Reporter: Roland Hänel
>
> If a client submits a POST with Content-Length 0, the HttpCore framework will fire the onContentReceived(...) method of the HttpAsyncRequestConsumer once. However, the decoder (passed as an argument to onContentReceived()) will never enter the "completed" state, because no bytes will actually be received from the client. However, reaching the "completed" stage of the decoder is an requirement for the HttpAsyncServiceHandler to finally process the request (i.e., call the handle(...) method).
> This leads to the (incorrect) behavior that it is impossible to handle a POST request with Content-Length 0 in HttpCore NIO.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Resolved] (HTTPCORE-296) Server HTTP connections incorrectly handle entity enclosing requests containing neither Content-Length nor Transfer-Encoding headers

Posted by "Oleg Kalnichevski (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCORE-296.
----------------------------------------

    Resolution: Fixed

Fixed in trunk and 4.1.x branch. Please review and re-test.

Oleg
                
> Server HTTP connections incorrectly handle entity enclosing requests containing neither Content-Length nor Transfer-Encoding headers
> ------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-296
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-296
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.2-alpha2
>            Reporter: Roland Hänel
>             Fix For: 4.2-beta2
>
>
> If a client submits a POST with Content-Length 0, the HttpCore framework will fire the onContentReceived(...) method of the HttpAsyncRequestConsumer once. However, the decoder (passed as an argument to onContentReceived()) will never enter the "completed" state, because no bytes will actually be received from the client. However, reaching the "completed" stage of the decoder is an requirement for the HttpAsyncServiceHandler to finally process the request (i.e., call the handle(...) method).
> This leads to the (incorrect) behavior that it is impossible to handle a POST request with Content-Length 0 in HttpCore NIO.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Commented] (HTTPCORE-296) IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)

Posted by "Oleg Kalnichevski (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13227945#comment-13227945 ] 

Oleg Kalnichevski commented on HTTPCORE-296:
--------------------------------------------

The way I interpret the spec an entity enclosing request MAY have no content body but it MUST make it clear by including 'Content-Lenght: 0' header. I still think sending back status 400 in such a case is the right thing to do. One can still (quite) easily override the default behavior by using a custom ContentLengthStrategy implementation.

Oleg 
                
> IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)
> -----------------------------------------------------------------------------
>
>                 Key: HTTPCORE-296
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-296
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.2-alpha2
>            Reporter: Roland Hänel
>             Fix For: 4.2-beta2
>
>
> If a client submits a POST with Content-Length 0, the HttpCore framework will fire the onContentReceived(...) method of the HttpAsyncRequestConsumer once. However, the decoder (passed as an argument to onContentReceived()) will never enter the "completed" state, because no bytes will actually be received from the client. However, reaching the "completed" stage of the decoder is an requirement for the HttpAsyncServiceHandler to finally process the request (i.e., call the handle(...) method).
> This leads to the (incorrect) behavior that it is impossible to handle a POST request with Content-Length 0 in HttpCore NIO.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Commented] (HTTPCORE-296) IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)

Posted by "Roland Hänel (Commented JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13227905#comment-13227905 ] 

Roland Hänel commented on HTTPCORE-296:
---------------------------------------

Hi Oleg,

Thanks for the quick reply. However one might doubt whether the solution is really that easy. I don't think the spec is 100% clear on this issue. Section 4.1 specifies the message body optional; section 4.3 says that "The presence of a message-body in a request is signaled by the inclusion of a Content-Length or Transfer-Encoding header field in the request's message-headers." We all know that POST messages usually have a message body, but I don't think we can read from the spec that it MUST have one.

If in doubt, might I suggest that a better solution could be to handle an entity enclosing request without message body by using a LengthDelimitedDecoder and a length of 0. This should also work out of the box and ensure the 'obviously expected behavior'.

-Roland
                
> IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)
> -----------------------------------------------------------------------------
>
>                 Key: HTTPCORE-296
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-296
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.2-alpha2
>            Reporter: Roland Hänel
>             Fix For: 4.2-beta2
>
>
> If a client submits a POST with Content-Length 0, the HttpCore framework will fire the onContentReceived(...) method of the HttpAsyncRequestConsumer once. However, the decoder (passed as an argument to onContentReceived()) will never enter the "completed" state, because no bytes will actually be received from the client. However, reaching the "completed" stage of the decoder is an requirement for the HttpAsyncServiceHandler to finally process the request (i.e., call the handle(...) method).
> This leads to the (incorrect) behavior that it is impossible to handle a POST request with Content-Length 0 in HttpCore NIO.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Commented] (HTTPCORE-296) IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)

Posted by "Roland Hänel (Commented JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13227904#comment-13227904 ] 

Roland Hänel commented on HTTPCORE-296:
---------------------------------------

Hi Oleg,

Thanks for the quick reply. However one might doubt whether the solution is really that easy. I don't think the spec is 100% clear on this issue. Section 4.1 specifies the message body optional; section 4.3 says that "The presence of a message-body in a request is signaled by the inclusion of a Content-Length or Transfer-Encoding header field in the request's message-headers." We all know that POST messages usually have a message body, but I don't think we can read from the spec that it MUST have one.

If in doubt, might I suggest that a better solution could be to handle an entity enclosing request without message body by using a LengthDelimitedDecoder and a length of 0. This should also work out of the box and ensure the 'obviously expected behavior'.

-Roland
                
> IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)
> -----------------------------------------------------------------------------
>
>                 Key: HTTPCORE-296
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-296
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.2-alpha2
>            Reporter: Roland Hänel
>             Fix For: 4.2-beta2
>
>
> If a client submits a POST with Content-Length 0, the HttpCore framework will fire the onContentReceived(...) method of the HttpAsyncRequestConsumer once. However, the decoder (passed as an argument to onContentReceived()) will never enter the "completed" state, because no bytes will actually be received from the client. However, reaching the "completed" stage of the decoder is an requirement for the HttpAsyncServiceHandler to finally process the request (i.e., call the handle(...) method).
> This leads to the (incorrect) behavior that it is impossible to handle a POST request with Content-Length 0 in HttpCore NIO.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Commented] (HTTPCORE-296) IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)

Posted by "Oleg Kalnichevski (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13230993#comment-13230993 ] 

Oleg Kalnichevski commented on HTTPCORE-296:
--------------------------------------------

Curl also does not include 'Content-Length: 0' header if one does not specify any content to post. I think this is wrong, but I'll make sure HttpCore can handle such requests.

Oleg 
                
> IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)
> -----------------------------------------------------------------------------
>
>                 Key: HTTPCORE-296
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-296
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.2-alpha2
>            Reporter: Roland Hänel
>             Fix For: 4.2-beta2
>
>
> If a client submits a POST with Content-Length 0, the HttpCore framework will fire the onContentReceived(...) method of the HttpAsyncRequestConsumer once. However, the decoder (passed as an argument to onContentReceived()) will never enter the "completed" state, because no bytes will actually be received from the client. However, reaching the "completed" stage of the decoder is an requirement for the HttpAsyncServiceHandler to finally process the request (i.e., call the handle(...) method).
> This leads to the (incorrect) behavior that it is impossible to handle a POST request with Content-Length 0 in HttpCore NIO.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Updated] (HTTPCORE-296) Server HTTP connections incorrectly handle entity enclosing requests containing neither Content-Length nor Transfer-Encoding headers

Posted by "Oleg Kalnichevski (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski updated HTTPCORE-296:
---------------------------------------

    Summary: Server HTTP connections incorrectly handle entity enclosing requests containing neither Content-Length nor Transfer-Encoding headers  (was: IdentityDecoder fails to consume as POST request with Content-Length 0 (zero))
    
> Server HTTP connections incorrectly handle entity enclosing requests containing neither Content-Length nor Transfer-Encoding headers
> ------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-296
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-296
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.2-alpha2
>            Reporter: Roland Hänel
>             Fix For: 4.2-beta2
>
>
> If a client submits a POST with Content-Length 0, the HttpCore framework will fire the onContentReceived(...) method of the HttpAsyncRequestConsumer once. However, the decoder (passed as an argument to onContentReceived()) will never enter the "completed" state, because no bytes will actually be received from the client. However, reaching the "completed" stage of the decoder is an requirement for the HttpAsyncServiceHandler to finally process the request (i.e., call the handle(...) method).
> This leads to the (incorrect) behavior that it is impossible to handle a POST request with Content-Length 0 in HttpCore NIO.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Commented] (HTTPCORE-296) IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)

Posted by "Roland Hänel (Commented JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13227958#comment-13227958 ] 

Roland Hänel commented on HTTPCORE-296:
---------------------------------------

Thanks for pointing out the ContentLengthStrategy think. I'll try my luck there. :-)

Roland
                
> IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)
> -----------------------------------------------------------------------------
>
>                 Key: HTTPCORE-296
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-296
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.2-alpha2
>            Reporter: Roland Hänel
>             Fix For: 4.2-beta2
>
>
> If a client submits a POST with Content-Length 0, the HttpCore framework will fire the onContentReceived(...) method of the HttpAsyncRequestConsumer once. However, the decoder (passed as an argument to onContentReceived()) will never enter the "completed" state, because no bytes will actually be received from the client. However, reaching the "completed" stage of the decoder is an requirement for the HttpAsyncServiceHandler to finally process the request (i.e., call the handle(...) method).
> This leads to the (incorrect) behavior that it is impossible to handle a POST request with Content-Length 0 in HttpCore NIO.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] [Updated] (HTTPCORE-296) IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)

Posted by "Oleg Kalnichevski (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski updated HTTPCORE-296:
---------------------------------------

    Fix Version/s: 4.2-beta2

An entity enclosing request that does not deliniate its content either with Transfer-Encoding or Content-Length header is invalid per section 4.1 of the HTTP/1.1 spec. The problem is that HttpCore attempts to consume the request by using identity codec instead of rejecting it as invalid.

Oleg
                
> IdentityDecoder fails to consume as POST request with Content-Length 0 (zero)
> -----------------------------------------------------------------------------
>
>                 Key: HTTPCORE-296
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-296
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.2-alpha2
>            Reporter: Roland Hänel
>             Fix For: 4.2-beta2
>
>
> If a client submits a POST with Content-Length 0, the HttpCore framework will fire the onContentReceived(...) method of the HttpAsyncRequestConsumer once. However, the decoder (passed as an argument to onContentReceived()) will never enter the "completed" state, because no bytes will actually be received from the client. However, reaching the "completed" stage of the decoder is an requirement for the HttpAsyncServiceHandler to finally process the request (i.e., call the handle(...) method).
> This leads to the (incorrect) behavior that it is impossible to handle a POST request with Content-Length 0 in HttpCore NIO.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org