remm        02/03/08 20:39:21

  Modified:    http11/src/java/org/apache/coyote/http11
                        Http11Processor.java
  Log:
  - Fixes problems with requests having a content-length of 0.
  - Fixes problems with HTTP/1.1 requests without a content-length (although
    this may not be totally legal).
  
  Revision  Changes    Path
  1.4       +15 -12    
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java
  
  Index: Http11Processor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11Processor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Http11Processor.java      8 Mar 2002 23:47:19 -0000       1.3
  +++ Http11Processor.java      9 Mar 2002 04:39:21 -0000       1.4
  @@ -271,13 +271,9 @@
                   // Check for HTTP/0.9
                   
                   inputBuffer.parseHeaders();
  -            } catch (EOFException e) {
  +            } catch (IOException e) {
                   error = true;
                   break;
  -            } catch (InterruptedIOException e) {
  -                e.printStackTrace();
  -                //HttpServletResponse.SC_BAD_REQUEST
  -                error = true;
               } catch (Exception e) {
                   e.printStackTrace();
                   //SC_BAD_REQUEST
  @@ -291,7 +287,6 @@
               try {
                   adapter.service(request, response);
               } catch (InterruptedIOException e) {
  -                e.printStackTrace();
                   error = true;
               } catch (Throwable t) {
                   // ISE
  @@ -303,7 +298,6 @@
               try {
                   inputBuffer.endRequest();
               } catch (IOException e) {
  -                e.printStackTrace();
                   error = true;
               } catch (Throwable t) {
                   // Problem ...
  @@ -313,7 +307,6 @@
               try {
                   outputBuffer.endRequest();
               } catch (IOException e) {
  -                e.printStackTrace();
                   error = true;
               } catch (Throwable t) {
                   // Problem ...
  @@ -505,10 +498,15 @@
   
           // Parse content-length header
           int contentLength = request.getContentLength();
  -        if (contentLength != -1) {
  +        if (contentLength > 0) {
               inputBuffer.addActiveFilter
                   (inputFilters[Constants.IDENTITY_FILTER]);
               contentDelimitation = true;
  +        } else if (contentLength == 0) {
  +            // No content to read
  +            inputBuffer.addActiveFilter
  +                (inputFilters[Constants.VOID_FILTER]);
  +            contentDelimitation = true;
           }
   
           // Parse transfer-encoding header
  @@ -552,10 +550,15 @@
           }
   
           if (!contentDelimitation) {
  +            /*
               // If method is GET or HEAD, prevent from reading any content
  -            if ((methodMB.equals("GET"))
  -                || (methodMB.equals("HEAD"))
  -                || (methodMB.equals("TRACE"))) {
  +              if ((methodMB.equals("GET"))
  +              || (methodMB.equals("HEAD"))
  +              || (methodMB.equals("TRACE"))) {
  +            */
  +            // If there's no content length and we're using HTTP/1.1, assume
  +            // the client is not broken and didn't send a body
  +            if (http11) {
                   inputBuffer.addActiveFilter
                       (inputFilters[Constants.VOID_FILTER]);
                   contentDelimitation = true;
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to