You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Arun G <ar...@yahoo.com> on 2004/03/04 18:09:46 UTC

HTTPClient hangs

Hi folks,
    I am using multipart form post to upload a file.
The server side is production code that we are using
to upload files with other modules using multipart
form post. The failure/hang is happening only with the
HTTP Client code that I have pasted here. Also it is
worth noting that the server does a redirect after the
file is uploaded. But I don't even the response code
back since it just seems to stiing there at the
executemethod call. I was wondering if someone could
help me figure out what may be wrong here.
 
The executemethod never returns. From the trace it
looks like the the function HTTPParser.readRawLine
does not return. Here are the last few lines of the
trace and the source code that is being used. I am
running this under the following JVM version :

java version "1.4.1_06"
Java(TM) 2 Runtime Environment, Standard Edition
(build 1.4.1_06-b01)
Java HotSpot(TM) Client VM (build 1.4.1_06-b01, mixed
mode)

004/03/04 09:02:49:148 PST [TRACE] HttpConnection -
-enter HttpConnection.flushRequestOutputStream()
004/03/04 09:02:49:158 PST [TRACE] HttpMethodBase -
-enter HttpMethodBase.readResponse(HttpState,
HttpConnection)
004/03/04 09:02:49:158 PST [TRACE] HttpMethodBase -
-enter HttpMethodBase.readStatusLine(HttpState,
HttpConnection)
004/03/04 09:02:49:158 PST [TRACE] HttpConnection -
-enter HttpConnection.readLine()
004/03/04 09:02:49:158 PST [TRACE] HttpParser - -enter
HttpParser.readLine()
004/03/04 09:02:49:158 PST [TRACE] HttpParser - -enter
HttpParser.readRawLine()


HttpClient httpClient = new HttpClient();
        MultipartPostMethod multipartPostMethod = new
MultipartPostMethod(urlString);
        java.util.Enumeration formEnum =
formVariableHash.keys();
        while (formEnum.hasMoreElements())
        {
            String name = (String)
formEnum.nextElement();
            String value =
formVariableHash.get(name).toString();
            StringPart stringPart = new
StringPart(name, value);
            multipartPostMethod.addPart(stringPart);
        }
        try
        {
            FilePart filePart = new
FilePart("file_to_upload", binaryFile.getName(),
binaryFile);
            multipartPostMethod.addPart(filePart);
            if (!multipartPostMethod.validate())
            {
                throw new FileuploadException("Unable
to upload File " + uploadFileName + ". Error when
posting form information");
            }
            int responseCode =
httpClient.executeMethod(multipartPostMethod);
            ArenaApp.getInstance().logMessage("File
upload responseCode= " + responseCode);
                    }

__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you�re looking for faster
http://search.yahoo.com

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


Re: HTTPClient hangs

Posted by Arun G <ar...@yahoo.com>.
Never mind my post. I just figured out I was using a
wrong version of a modified HTTPClient. Sorry I wasted
your time.  Ignore my previous post.

Regards,
Arun
--- Michael Becke <be...@u.washington.edu> wrote:
> Hi Arun,
> 
> It seems that the server never responds to the
> request.  My only guess 
> is that it's related to inconsistencies with how
> different servers 
> handle multi part posts.  In particular, some
> servers seem to have 
> trouble with content-type and transfer encoding. 
> Please try setting 
> both of these values to null for each of the string
> and file parts 
> being posted.
> 
> Mike
> 
> On Mar 4, 2004, at 12:09 PM, Arun G wrote:
> 
> > Hi folks,
> >     I am using multipart form post to upload a
> file.
> > The server side is production code that we are
> using
> > to upload files with other modules using multipart
> > form post. The failure/hang is happening only with
> the
> > HTTP Client code that I have pasted here. Also it
> is
> > worth noting that the server does a redirect after
> the
> > file is uploaded. But I don't even the response
> code
> > back since it just seems to stiing there at the
> > executemethod call. I was wondering if someone
> could
> > help me figure out what may be wrong here.
> >
> > The executemethod never returns. From the trace it
> > looks like the the function HTTPParser.readRawLine
> > does not return. Here are the last few lines of
> the
> > trace and the source code that is being used. I am
> > running this under the following JVM version :
> >
> > java version "1.4.1_06"
> > Java(TM) 2 Runtime Environment, Standard Edition
> > (build 1.4.1_06-b01)
> > Java HotSpot(TM) Client VM (build 1.4.1_06-b01,
> mixed
> > mode)
> >
> > 004/03/04 09:02:49:148 PST [TRACE] HttpConnection
> -
> > -enter HttpConnection.flushRequestOutputStream()
> > 004/03/04 09:02:49:158 PST [TRACE] HttpMethodBase
> -
> > -enter HttpMethodBase.readResponse(HttpState,
> > HttpConnection)
> > 004/03/04 09:02:49:158 PST [TRACE] HttpMethodBase
> -
> > -enter HttpMethodBase.readStatusLine(HttpState,
> > HttpConnection)
> > 004/03/04 09:02:49:158 PST [TRACE] HttpConnection
> -
> > -enter HttpConnection.readLine()
> > 004/03/04 09:02:49:158 PST [TRACE] HttpParser -
> -enter
> > HttpParser.readLine()
> > 004/03/04 09:02:49:158 PST [TRACE] HttpParser -
> -enter
> > HttpParser.readRawLine()
> >
> >
> > HttpClient httpClient = new HttpClient();
> >         MultipartPostMethod multipartPostMethod =
> new
> > MultipartPostMethod(urlString);
> >         java.util.Enumeration formEnum =
> > formVariableHash.keys();
> >         while (formEnum.hasMoreElements())
> >         {
> >             String name = (String)
> > formEnum.nextElement();
> >             String value =
> > formVariableHash.get(name).toString();
> >             StringPart stringPart = new
> > StringPart(name, value);
> >            
> multipartPostMethod.addPart(stringPart);
> >         }
> >         try
> >         {
> >             FilePart filePart = new
> > FilePart("file_to_upload", binaryFile.getName(),
> > binaryFile);
> >             multipartPostMethod.addPart(filePart);
> >             if (!multipartPostMethod.validate())
> >             {
> >                 throw new
> FileuploadException("Unable
> > to upload File " + uploadFileName + ". Error when
> > posting form information");
> >             }
> >             int responseCode =
> > httpClient.executeMethod(multipartPostMethod);
> >            
> ArenaApp.getInstance().logMessage("File
> > upload responseCode= " + responseCode);
> >                     }
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Search - Find what you�re looking for
> faster
> > http://search.yahoo.com
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail: 
> >
>
commons-httpclient-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: 
> > commons-httpclient-dev-help@jakarta.apache.org
> >
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
>
commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-httpclient-dev-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you�re looking for faster
http://search.yahoo.com

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


Re: HTTPClient hangs

Posted by Michael Becke <be...@u.washington.edu>.
Hi Arun,

It seems that the server never responds to the request.  My only guess 
is that it's related to inconsistencies with how different servers 
handle multi part posts.  In particular, some servers seem to have 
trouble with content-type and transfer encoding.  Please try setting 
both of these values to null for each of the string and file parts 
being posted.

Mike

On Mar 4, 2004, at 12:09 PM, Arun G wrote:

> Hi folks,
>     I am using multipart form post to upload a file.
> The server side is production code that we are using
> to upload files with other modules using multipart
> form post. The failure/hang is happening only with the
> HTTP Client code that I have pasted here. Also it is
> worth noting that the server does a redirect after the
> file is uploaded. But I don't even the response code
> back since it just seems to stiing there at the
> executemethod call. I was wondering if someone could
> help me figure out what may be wrong here.
>
> The executemethod never returns. From the trace it
> looks like the the function HTTPParser.readRawLine
> does not return. Here are the last few lines of the
> trace and the source code that is being used. I am
> running this under the following JVM version :
>
> java version "1.4.1_06"
> Java(TM) 2 Runtime Environment, Standard Edition
> (build 1.4.1_06-b01)
> Java HotSpot(TM) Client VM (build 1.4.1_06-b01, mixed
> mode)
>
> 004/03/04 09:02:49:148 PST [TRACE] HttpConnection -
> -enter HttpConnection.flushRequestOutputStream()
> 004/03/04 09:02:49:158 PST [TRACE] HttpMethodBase -
> -enter HttpMethodBase.readResponse(HttpState,
> HttpConnection)
> 004/03/04 09:02:49:158 PST [TRACE] HttpMethodBase -
> -enter HttpMethodBase.readStatusLine(HttpState,
> HttpConnection)
> 004/03/04 09:02:49:158 PST [TRACE] HttpConnection -
> -enter HttpConnection.readLine()
> 004/03/04 09:02:49:158 PST [TRACE] HttpParser - -enter
> HttpParser.readLine()
> 004/03/04 09:02:49:158 PST [TRACE] HttpParser - -enter
> HttpParser.readRawLine()
>
>
> HttpClient httpClient = new HttpClient();
>         MultipartPostMethod multipartPostMethod = new
> MultipartPostMethod(urlString);
>         java.util.Enumeration formEnum =
> formVariableHash.keys();
>         while (formEnum.hasMoreElements())
>         {
>             String name = (String)
> formEnum.nextElement();
>             String value =
> formVariableHash.get(name).toString();
>             StringPart stringPart = new
> StringPart(name, value);
>             multipartPostMethod.addPart(stringPart);
>         }
>         try
>         {
>             FilePart filePart = new
> FilePart("file_to_upload", binaryFile.getName(),
> binaryFile);
>             multipartPostMethod.addPart(filePart);
>             if (!multipartPostMethod.validate())
>             {
>                 throw new FileuploadException("Unable
> to upload File " + uploadFileName + ". Error when
> posting form information");
>             }
>             int responseCode =
> httpClient.executeMethod(multipartPostMethod);
>             ArenaApp.getInstance().logMessage("File
> upload responseCode= " + responseCode);
>                     }
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Search - Find what you’re looking for faster
> http://search.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> commons-httpclient-dev-help@jakarta.apache.org
>


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