hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Redirection not happening?
Date Thu, 18 Feb 2016 09:50:47 GMT
On Wed, 2016-02-17 at 09:28 -0500, Karl Wright wrote:
> Thanks; this is indeed a POST.
> 
> Karl
> 

Hi Karl

There are restrictions on automatic redirection of POST methods imposed
by the HTTP spec. There is a short summary of how HttpClient handles
redirects in the DefaultRedirectStrategy

http://hc.apache.org/httpcomponents-client-4.5.x/httpclient/xref/org/apache/http/impl/client/DefaultRedirectStrategy.html#58

If you want your application to be able to redirect POST requests
without modification you should subclass DefaultRedirectStrategy and
customize its behavior.

Hope this helps

Oleg

> 
> On Wed, Feb 17, 2016 at 9:04 AM, Oleg Kalnichevski <olegk@apache.org> wrote:
> 
> > On Tue, 2016-02-16 at 17:03 -0500, Karl Wright wrote:
> > > Oh, FWIW, this is httpcomponents/httpclient 4.4.1.
> > > Karl
> > >
> > >
> >
> > Hi Karl
> >
> > What kind of request method is it? Per RFC 2616 there are certain
> > restrictions on automatic redirects of some methods such as POST and
> > PUT.
> >
> > Oleg
> >
> > > On Tue, Feb 16, 2016 at 4:58 PM, Karl Wright <daddywri@gmail.com> wrote:
> > >
> > > > Hi folks,
> > > >
> > > > The ManifoldCF SharePoint connector has the following code to set up
> > its
> > > > HttpClient instance:
> > > >
> > > > >>>>>>
> > > >       RequestConfig.Builder requestBuilder = RequestConfig.custom()
> > > >           .setCircularRedirectsAllowed(true)
> > > >           .setSocketTimeout(socketTimeout)
> > > >           .setExpectContinueEnabled(false)
> > > >           .setConnectTimeout(connectionTimeout)
> > > >           .setConnectionRequestTimeout(socketTimeout);
> > > >
> > > >       // If there's a proxy, set that too.
> > > >       if (proxyHost != null && proxyHost.length() > 0)
> > > >       {
> > > >
> > > >         // Configure proxy authentication
> > > >         if (proxyUsername != null && proxyUsername.length() >
0)
> > > >         {
> > > >           if (proxyPassword == null)
> > > >             proxyPassword = "";
> > > >           if (proxyDomain == null)
> > > >             proxyDomain = "";
> > > >
> > > >           credentialsProvider.setCredentials(
> > > >             new AuthScope(proxyHost, proxyPort),
> > > >             new NTCredentials(proxyUsername, proxyPassword,
> > currentHost,
> > > > proxyDomain));
> > > >         }
> > > >
> > > >         HttpHost proxy = new HttpHost(proxyHost, proxyPort);
> > > >
> > > >         requestBuilder.setProxy(proxy);
> > > >       }
> > > >
> > > >       HttpClientBuilder builder = HttpClients.custom()
> > > >         .setConnectionManager(connectionManager)
> > > >         .disableAutomaticRetries()
> > > >         .setDefaultRequestConfig(requestBuilder.build())
> > > >         .setDefaultCredentialsProvider(credentialsProvider);
> > > >       builder.setRequestExecutor(new
> > HttpRequestExecutor(socketTimeout))
> > > >         .setRedirectStrategy(new DefaultRedirectStrategy());
> > > >       httpClient = builder.build();
> > > > <<<<<<
> > > >
> > > > This works fine for the most part, except for one thing: it apparently
> > > > doesn't follow 302 redirections, for some reason.  Any idea why?
> > > >
> > > > Thanks in advance,
> > > > Karl
> > > >
> > > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> > For additional commands, e-mail: dev-help@hc.apache.org
> >
> >



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


Mime
View raw message