You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Ronald E Johnson (JIRA)" <ji...@apache.org> on 2008/01/07 21:22:34 UTC

[jira] Created: (HTTPCORE-137) Problem handling HTTP PUT requests

Problem handling HTTP PUT requests 
-----------------------------------

                 Key: HTTPCORE-137
                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
             Project: HttpComponents Core
          Issue Type: Bug
          Components: HttpCore NIO
    Affects Versions: 4.0-rc1
         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
            Reporter: Ronald E Johnson


I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:

if (request instanceof HttpEntityEnclosingRequest)  {
            HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
            byte[] entityContent = EntityUtils.toByteArray(entity);
            logger.info("Incoming entity content (bytes): " + entityContent.length);
}

However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Issue Comment Edited: (HTTPCORE-137) Problem handling HTTP PUT requests

Posted by "Ronald E Johnson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12557427#action_12557427 ] 

rejohnson edited comment on HTTPCORE-137 at 1/9/08 12:49 PM:
--------------------------------------------------------------------

Actually after going through the HttpComponents core code base, it looks like the PUT requests are never handled.  In the file module-main/src/main/java/org/apache/http/impl/DefaultHttpRequestFactory.java the source code looks like:

    public HttpRequest newHttpRequest(final RequestLine requestline)
            throws MethodNotSupportedException {
        if (requestline == null) {
            throw new IllegalArgumentException("Request line may not be null");
        }
        String method = requestline.getMethod();
        if ("GET".equalsIgnoreCase(method)) {
            return new BasicHttpRequest(requestline); 
        } else if ("HEAD".equalsIgnoreCase(method)) {
            return new BasicHttpRequest(requestline); 
        } else if ("POST".equalsIgnoreCase(method)) {
            return new BasicHttpEntityEnclosingRequest(requestline); 
        } else { 
            throw new MethodNotSupportedException(method +  " method not supported");
        }
    }

Notice that "PUT" is never handled.  Which is why I've been getting a "501 method not supported" message.  After changing the code to:

    public HttpRequest newHttpRequest(final RequestLine requestline)
            throws MethodNotSupportedException {
        if (requestline == null) {
            throw new IllegalArgumentException("Request line may not be null");
        }
        String method = requestline.getMethod();
        if ("GET".equalsIgnoreCase(method)) {
            return new BasicHttpRequest(requestline); 
        } else if ("HEAD".equalsIgnoreCase(method)) {
            return new BasicHttpRequest(requestline); 
        } else if ("PUT".equalsIgnoreCase(method)) {
            return new BasicHttpEntityEnclosingRequest(requestline); 
        } else if ("POST".equalsIgnoreCase(method)) {
            return new BasicHttpEntityEnclosingRequest(requestline); 
        } else { 
            throw new MethodNotSupportedException(method +  " method not supported");
        }
    }

I was able to process the PUT request...  Thanks for your patience.  I have updated the test code and provided the modified org.apache.http.impl.DefaultHttpRequestFactory class.

      was (Author: rejohnson):
    Actually after going through the HttpComponents core code base, it looks like the PUT requests are never handled.  In the file module-main/src/main/java/org/apache/http/impl/DefaultHttpRequestFactory.java the source code looks like:

    public HttpRequest newHttpRequest(final RequestLine requestline)
            throws MethodNotSupportedException {
        if (requestline == null) {
            throw new IllegalArgumentException("Request line may not be null");
        }
        String method = requestline.getMethod();
        if ("GET".equalsIgnoreCase(method)) {
            return new BasicHttpRequest(requestline); 
        } else if ("HEAD".equalsIgnoreCase(method)) {
            return new BasicHttpRequest(requestline); 
        } else if ("POST".equalsIgnoreCase(method)) {
            return new BasicHttpEntityEnclosingRequest(requestline); 
        } else { 
            throw new MethodNotSupportedException(method +  " method not supported");
        }
    }

Notice that "PUT" is never handled.  Which is why I've been getting a "501 method not supported" message.  After changing the code to:

    public HttpRequest newHttpRequest(final RequestLine requestline)
            throws MethodNotSupportedException {
        if (requestline == null) {
            throw new IllegalArgumentException("Request line may not be null");
        }
        String method = requestline.getMethod();
        if ("GET".equalsIgnoreCase(method)) {
            return new BasicHttpRequest(requestline); 
        } else if ("HEAD".equalsIgnoreCase(method)) {
            return new BasicHttpRequest(requestline); 
        } else if ("PUT".equalsIgnoreCase(method)) {
            return new BasicHttpEntityEnclosingRequest(requestline); 
        } else if ("POST".equalsIgnoreCase(method)) {
            return new BasicHttpEntityEnclosingRequest(requestline); 
        } else { 
            throw new MethodNotSupportedException(method +  " method not supported");
        }
    }

I was able to process the PUT request...  Thanks for your patience.  I will update the test code and provided the modified DefaultHttpRequestFactory.java file.
  
> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>         Attachments: DefaultHttpRequestFactory.java, TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (HTTPCORE-137) Problem handling HTTP PUT requests

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

Ronald E Johnson updated HTTPCORE-137:
--------------------------------------

    Attachment:     (was: TestHTTPServer.java)

> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>         Attachments: TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (HTTPCORE-137) Problem handling HTTP PUT requests

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

Ronald E Johnson updated HTTPCORE-137:
--------------------------------------

    Attachment: TestHTTPServer.java

> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>         Attachments: DefaultHttpRequestFactory.java, TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCORE-137) Problem handling HTTP PUT requests

Posted by "Roland Weber (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12557296#action_12557296 ] 

Roland Weber commented on HTTPCORE-137:
---------------------------------------

Your PUT clients are obviously sending a HEAD request _before_ the PUT request, probably to verify that the resource to put doesn't exist yet. I suggest you handle the HEAD request as the HEAD request that it is, and then wait for the subsequent PUT request.


> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>         Attachments: TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Resolved: (HTTPCORE-137) Problem handling HTTP PUT requests

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

Oleg Kalnichevski resolved HTTPCORE-137.
----------------------------------------

    Resolution: Fixed

> Are you sending a message entity in response to the HEAD request? 

This is actually necessary to be able to generate Content-Length/TransferEncoding headers correctly. Protocol handlers are expected to discard entities sent in response to HEAD requests.

> Ronald,

Had you actually mentioned getting "501 method not supported" instead of saying HTTP PUTs were not working, the problem would have been tracked down to the HttpRequestFactory almost immediately.

Fixed.

Oleg

> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Improvement
>          Components: HttpCore
>    Affects Versions: 4.0-alpha6
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>            Assignee: Roland Weber
>            Priority: Minor
>             Fix For: 4.0-beta1
>
>         Attachments: DefaultHttpRequestFactory.java, TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCORE-137) Problem handling HTTP PUT requests

Posted by "Ortwin Glück (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12556759#action_12556759 ] 

Ortwin Glück commented on HTTPCORE-137:
---------------------------------------

You are seeing a HEAD, because it *is* a HEAD. Please use a packet sniffer like tcpdump or Wireshark if and inspect the traffic directly on the wire, if you are still having doubts.

> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>         Attachments: TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCORE-137) Problem handling HTTP PUT requests

Posted by "Roland Weber (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12557309#action_12557309 ] 

Roland Weber commented on HTTPCORE-137:
---------------------------------------

Are you sending a message entity in response to the HEAD request?
Then the client probably chokes on this gross violation of the HTTP specification.
Try a "501 not implemented" response, or "404 not found".
Without an entity, of course.

You may also consider to send your questions to the dev@ list.
An issue tracker is not a discussion forum.

cheers,
  Roland


> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>         Attachments: TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Closed: (HTTPCORE-137) Problem handling HTTP PUT requests

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

Roland Weber closed HTTPCORE-137.
---------------------------------

    Resolution: Invalid

Please fix this condition in your code:

if (method.equals("HEAD") || method.equals("PUT")) {
            	System.out.println("Processing PUT request...");



> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>         Attachments: TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (HTTPCORE-137) Problem handling HTTP PUT requests

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

Ronald E Johnson updated HTTPCORE-137:
--------------------------------------

    Priority: Minor  (was: Major)

> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>            Priority: Minor
>         Attachments: DefaultHttpRequestFactory.java, TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Reopened: (HTTPCORE-137) Problem handling HTTP PUT requests

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

Ronald E Johnson reopened HTTPCORE-137:
---------------------------------------


> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>            Priority: Minor
>         Attachments: DefaultHttpRequestFactory.java, TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCORE-137) Problem handling HTTP PUT requests

Posted by "Ronald E Johnson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12556743#action_12556743 ] 

Ronald E Johnson commented on HTTPCORE-137:
-------------------------------------------

Unfortunately the PUT request is never seen, so if I remove the method.equals("HEAD") condition, the request is never processed by the server.

Notice the request line printout:  "Request Line: HEAD /test.txt HTTP/1.1"

How do get the server to see the PUT requests as a PUT and not a HEAD request?




> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>         Attachments: TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (HTTPCORE-137) Problem handling HTTP PUT requests

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

Roland Weber updated HTTPCORE-137:
----------------------------------

          Component/s:     (was: HttpCore NIO)
                       HttpCore
        Fix Version/s: 4.0-beta1
             Assignee: Roland Weber
           Issue Type: Improvement  (was: Bug)
    Affects Version/s:     (was: 4.0-rc1)
                       4.0-alpha6

Thanks for tracking the problem down. The DefaultHttpRequestFactory was obviously designed only as an example for the three most common methods. I suggest to extend this to support all methods specificed in RFC 2616 (except CONNECT) by default.
We will also need documentation for using core on the server side eventually. So much to do, so little time...

cheers,
  Roland

> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Improvement
>          Components: HttpCore
>    Affects Versions: 4.0-alpha6
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>            Assignee: Roland Weber
>            Priority: Minor
>             Fix For: 4.0-beta1
>
>         Attachments: DefaultHttpRequestFactory.java, TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCORE-137) Problem handling HTTP PUT requests

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

Oleg Kalnichevski commented on HTTPCORE-137:
--------------------------------------------

> In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1"

Maybe the server is indeed getting a HEAD request, which explains the fact why it does not implement HttpEntityEnclosingRequest, don't you think? 

> Is this functionality supported?

Yes, it is.

Please provide an isolated test case that reproduces the problem, otherwise I'll close this issue as invalid.

Oleg

> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCORE-137) Problem handling HTTP PUT requests

Posted by "Ronald E Johnson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12556744#action_12556744 ] 

Ronald E Johnson commented on HTTPCORE-137:
-------------------------------------------

Should I log this as a different bug, in that PUT requests show up as HEAD requests?

> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>         Attachments: TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (HTTPCORE-137) Problem handling HTTP PUT requests

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

Ronald E Johnson updated HTTPCORE-137:
--------------------------------------

    Attachment: TestHTTPServer.java

This is a version which handles the HEAD request and PUT requests separately.

> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>         Attachments: TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (HTTPCORE-137) Problem handling HTTP PUT requests

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

Ronald E Johnson updated HTTPCORE-137:
--------------------------------------

    Attachment: TestHTTPServer.java

Here's the test code.

> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>         Attachments: TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (HTTPCORE-137) Problem handling HTTP PUT requests

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

Ronald E Johnson updated HTTPCORE-137:
--------------------------------------

    Attachment: DefaultHttpRequestFactory.java

> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>         Attachments: DefaultHttpRequestFactory.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCORE-137) Problem handling HTTP PUT requests

Posted by "Ronald E Johnson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12557427#action_12557427 ] 

Ronald E Johnson commented on HTTPCORE-137:
-------------------------------------------

Actually after going through the HttpComponents core code base, it looks like the PUT requests are never handled.  In the file module-main/src/main/java/org/apache/http/impl/DefaultHttpRequestFactory.java the source code looks like:

    public HttpRequest newHttpRequest(final RequestLine requestline)
            throws MethodNotSupportedException {
        if (requestline == null) {
            throw new IllegalArgumentException("Request line may not be null");
        }
        String method = requestline.getMethod();
        if ("GET".equalsIgnoreCase(method)) {
            return new BasicHttpRequest(requestline); 
        } else if ("HEAD".equalsIgnoreCase(method)) {
            return new BasicHttpRequest(requestline); 
        } else if ("POST".equalsIgnoreCase(method)) {
            return new BasicHttpEntityEnclosingRequest(requestline); 
        } else { 
            throw new MethodNotSupportedException(method +  " method not supported");
        }
    }

Notice that "PUT" is never handled.  Which is why I've been getting a "501 method not supported" message.  After changing the code to:

    public HttpRequest newHttpRequest(final RequestLine requestline)
            throws MethodNotSupportedException {
        if (requestline == null) {
            throw new IllegalArgumentException("Request line may not be null");
        }
        String method = requestline.getMethod();
        if ("GET".equalsIgnoreCase(method)) {
            return new BasicHttpRequest(requestline); 
        } else if ("HEAD".equalsIgnoreCase(method)) {
            return new BasicHttpRequest(requestline); 
        } else if ("PUT".equalsIgnoreCase(method)) {
            return new BasicHttpEntityEnclosingRequest(requestline); 
        } else if ("POST".equalsIgnoreCase(method)) {
            return new BasicHttpEntityEnclosingRequest(requestline); 
        } else { 
            throw new MethodNotSupportedException(method +  " method not supported");
        }
    }

I was able to process the PUT request...  Thanks for your patience.  I will update the test code and provided the modified DefaultHttpRequestFactory.java file.

> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (HTTPCORE-137) Problem handling HTTP PUT requests

Posted by "Ronald E Johnson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12556736#action_12556736 ] 

Ronald E Johnson commented on HTTPCORE-137:
-------------------------------------------

When running the test code using Winie (http://jigsaw.w3.org/Winie), I get the following output:

connection from 10.0.0.2
Request: org.apache.http.message.BasicHttpRequest@1479feb
Request Line: HEAD /test.txt HTTP/1.1
Method: HEAD
Processing PUT request...
Printing HTTP headers:
Header: Date, Value: Mon, 07 Jan 2008 22:04:07 GMT
Header: Accept, Value: */*
Header: Host, Value: 10.0.0.2
Header: User-Agent, Value: Winie/1.0.10
Request Target: /test.txt
File Transfer: Mon Jan 07 17:04:07 EST 2008 IP: 10.0.0.2 Path: C:\temp\test.txt
Connection timed out: [closed]
connection closed from 10.0.0.2

The cast to an HttpEntityEnclosingRequest never happens.  The request line from Winie is seen as a HEAD request.  I've tried other PUT clients, but they give the same results.


> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>         Attachments: TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (HTTPCORE-137) Problem handling HTTP PUT requests

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

Ronald E Johnson updated HTTPCORE-137:
--------------------------------------

    Attachment:     (was: TestHTTPServer.java)

> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Issue Comment Edited: (HTTPCORE-137) Problem handling HTTP PUT requests

Posted by "Ronald E Johnson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-137?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12557307#action_12557307 ] 

rejohnson edited comment on HTTPCORE-137 at 1/9/08 8:26 AM:
-------------------------------------------------------------------

This is a version which handles the HEAD request and PUT requests separately.  It also only sees just the HEAD request.  Not sure why...

      was (Author: rejohnson):
    This is a version which handles the HEAD request and PUT requests separately.
  
> Problem handling HTTP PUT requests 
> -----------------------------------
>
>                 Key: HTTPCORE-137
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-137
>             Project: HttpComponents Core
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0-rc1
>         Environment: Java JDK 1.6.0_03 on Windows XP Service Pack 2
>            Reporter: Ronald E Johnson
>         Attachments: TestHTTPServer.java
>
>
> I have a Java Swing application with an HttpServer() instance running in a SwingWorker thread.  I'm able to get at the HTTP GET requests by casting the request as follows:
> if (request instanceof HttpEntityEnclosingRequest)  {
>             HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
>             byte[] entityContent = EntityUtils.toByteArray(entity);
>             logger.info("Incoming entity content (bytes): " + entityContent.length);
> }
> However this does not work for PUT requests. In fact printing out the request line of a PUT request appears as: "HEAD /test.txt HTTP/1.1", and I don't see PUT in the request line at all.  Attempting to cast this as an HttpEntityEnclosingRequest fails, and thus I'm not able to get at the HttpEntity.  Is this functionality supported?  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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