You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by as...@sears.com on 2003/06/05 22:12:04 UTC

Status code of 100 on client.executeMethod();

Can anyone please let me know what does status code of 100 mean as a return
from client.executeMethod(post).
The result returns 100 and the subsequent code is not executed. I am not
able to retrieve the response as Stream.

Would appreciate if anyone can look at the code below to see if I have
missed anything that ought to be in the code.
This code is running under tomcat and is the alpha release before Release 2
beta 1.

          StringBuffer responseBody = new StringBuffer("");

          PostMethod method = null;
            String translatedString = "";

                  // Create the new HttpClient object
                  client = new HttpClient();

              //establish a connection within x seconds
              client.setConnectionTimeout(connectionTimeout);

              // Time it takes to receive the data after the connection is
established.
              client.setTimeout(timeout);

              //create a method object
              method = new PostMethod(sTheURL);

                  // Set the request body with the xml request
                  method.setRequestBody(sXML);

                  // Set the request headers
              method.setRequestHeader("Content-Type", " text/xml");
                  method.setRequestHeader("Content-Length",
translatedString.length() + "");

              int result = client.executeMethod(method);

              InputStream is = method.getResponseBodyAsStream();

              BufferedReader br = new BufferedReader(new
InputStreamReader(is));

              String line = null;
                while ((line = br.readLine()) != null)
                {
                   responseBody.append(line);
                }

              br.close();

              //clean up the connection resources
              method.releaseConnection();




Re: Status code of 100 on client.executeMethod();

Posted by Michael Becke <be...@u.washington.edu>.
It sounds like you are using Alpha 3.  I would suggest upgrading to Beta 
1.  Also, you should only need to set the content length if you are 
posting an InputStream.  In that case you should use 
post.setRequestContentLength().

Mike

asharm3@sears.com wrote:
> Can anyone please let me know what does status code of 100 mean as a return
> from client.executeMethod(post).
> The result returns 100 and the subsequent code is not executed. I am not
> able to retrieve the response as Stream.
> 
> Would appreciate if anyone can look at the code below to see if I have
> missed anything that ought to be in the code.
> This code is running under tomcat and is the alpha release before Release 2
> beta 1.
> 
>           StringBuffer responseBody = new StringBuffer("");
> 
>           PostMethod method = null;
>             String translatedString = "";
> 
>                   // Create the new HttpClient object
>                   client = new HttpClient();
> 
>               //establish a connection within x seconds
>               client.setConnectionTimeout(connectionTimeout);
> 
>               // Time it takes to receive the data after the connection is
> established.
>               client.setTimeout(timeout);
> 
>               //create a method object
>               method = new PostMethod(sTheURL);
> 
>                   // Set the request body with the xml request
>                   method.setRequestBody(sXML);
> 
>                   // Set the request headers
>               method.setRequestHeader("Content-Type", " text/xml");
>                   method.setRequestHeader("Content-Length",
> translatedString.length() + "");
> 
>               int result = client.executeMethod(method);
> 
>               InputStream is = method.getResponseBodyAsStream();
> 
>               BufferedReader br = new BufferedReader(new
> InputStreamReader(is));
> 
>               String line = null;
>                 while ((line = br.readLine()) != null)
>                 {
>                    responseBody.append(line);
>                 }
> 
>               br.close();
> 
>               //clean up the connection resources
>               method.releaseConnection();
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
> 


Re: Status code of 100 on client.executeMethod();

Posted by Oleg Kalnichevski <ol...@apache.org>.
100 status code is supposed to be used internally by HTTP agents when
engaging in so-called 'expect: 100-continue' handshake. The target HTTP
server responds with status code 100 to tell the client that it is ok to
send the request body. The purpose of 'expect: 100-continue' handshake
is to avoid sending request body (that can be fairly large) if some of
the headers do not satisfy the target HTTP server, for instance,
authentication credentials are not valid.

The 1xx range of status codes are for internal use only and should never
be returned to the user. This is definitely a bug in earlier versions of
HttpClient. 

There seems to be nothing wrong with your code. Just upgrade to 2.0beta1
Cheers

Oleg

On Thu, 2003-06-05 at 22:12, asharm3@sears.com wrote:
> Can anyone please let me know what does status code of 100 mean as a return
> from client.executeMethod(post).
> The result returns 100 and the subsequent code is not executed. I am not
> able to retrieve the response as Stream.
> 
> Would appreciate if anyone can look at the code below to see if I have
> missed anything that ought to be in the code.
> This code is running under tomcat and is the alpha release before Release 2
> beta 1.
> 
>           StringBuffer responseBody = new StringBuffer("");
> 
>           PostMethod method = null;
>             String translatedString = "";
> 
>                   // Create the new HttpClient object
>                   client = new HttpClient();
> 
>               //establish a connection within x seconds
>               client.setConnectionTimeout(connectionTimeout);
> 
>               // Time it takes to receive the data after the connection is
> established.
>               client.setTimeout(timeout);
> 
>               //create a method object
>               method = new PostMethod(sTheURL);
> 
>                   // Set the request body with the xml request
>                   method.setRequestBody(sXML);
> 
>                   // Set the request headers
>               method.setRequestHeader("Content-Type", " text/xml");
>                   method.setRequestHeader("Content-Length",
> translatedString.length() + "");
> 
>               int result = client.executeMethod(method);
> 
>               InputStream is = method.getResponseBodyAsStream();
> 
>               BufferedReader br = new BufferedReader(new
> InputStreamReader(is));
> 
>               String line = null;
>                 while ((line = br.readLine()) != null)
>                 {
>                    responseBody.append(line);
>                 }
> 
>               br.close();
> 
>               //clean up the connection resources
>               method.releaseConnection();
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org
>