commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pedro Salgado <salgado...@04web.com>
Subject Re: httpclient: HTTP/1.1 501 Not Implemented
Date Sun, 05 Jun 2005 11:45:19 GMT
I am executing a GET method.
If it is on the server side... That means I should be setting my request on
HTTP1.0?

        retryhandler = new DefaultMethodRetryHandler();
        retryhandler.setRequestSentRetryEnabled(true);
        retryhandler.setRetryCount(5);

        client = new HttpClient();
        client.getState().setAuthenticationPreemptive(true);

        Credentials defaultcreds = new UsernamePasswordCredentials("user",
"pass");
        client.getState().setCredentials(null, URL_X, defaultcreds);

        GetMethod method = createMethod(URL_Y);
        get(client, method);


    /**
     * @param httpClient
     * @param method
     */
    private static final byte[] get(final HttpClient httpClient, final
HttpMethod method) {

        byte[] responseBody = null;

        try {
            // Execute the method.
            int statusCode = httpClient.executeMethod(method);

            if (statusCode != HttpStatus.SC_OK) {
                System.err.println("Method failed: " +
method.getStatusLine());
            }

            // Read the response body.
            responseBody = method.getResponseBody();

        } catch (final HttpException e) {
            System.err.println("Fatal protocol violation: " +
e.getMessage());
            e.printStackTrace();
        } catch (final IOException e) {
            System.err.println("Fatal transport error: " + e.getMessage());
            e.printStackTrace();
        } finally {
            // Release the connection.
            method.releaseConnection();
        }

        return responseBody;
    }


Pedro Salgado

On 05/06/2005 12:52, "Ronald Klop" <ronald-freebsd8@klop.yi.org> wrote:

> On Sun, 05 Jun 2005 12:25:24 +0200, Pedro Salgado <salgado.pc@04web.com>
> wrote:
> 
>> 
>> When executing this:
>> 
>>             int statusCode = httpClient.executeMethod(method);
>> 
>>             if (statusCode != HttpStatus.SC_OK) {
>>                 System.err.println("Method failed: " +
>> method.getStatusLine());
>>             }
>> 
>> 
>> I am getting this message:
>> 
>> Method failed: HTTP/1.1 501 Not Implemented
>> 
>> Is there any workaround?
> 
> This is the reply of the server. What method are you executing?
> 
> Ronald.
> 


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


Mime
View raw message