|
View:
New views
14 Messages
—
Rating Filter:
Alert me
|
|
|
Question regarding the redirectsHello,
I am working on the application which fetches HTTP contents given the URL. If there is any redirection from the original URL, I need to find out what's the destination URL from which the contents are going to be fetched eventually. Then depending on the predefined criterion I would like to determine if the contents should be fetched from the final destination or not. For example, when I use HttpClient to fetch contents from URL: http://www.opensolaris.org/jive/login!withRedirect.jspa The request gets automatically redirected to https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909 and HttpClient returns the html contents from https://auth.opensolaris.... Based on the return code value from method.execute() call I have no way to know that this happened. The return code is 200 (HttpStatus.SC_OK). I have two questions as follows: 1> Is there any way to know that this redirect happened ? 2> Can I control redirects completely? Meaning, is there any way to tell HttpClient to not to fetch content from the new URL but just let the calling method know what this new URL is? Please note setting method.followRedirects() to true or false did not alter the behavior. Irrespective of setting this flag to false, the HTML contents were fetched from https://auth.opensolaris.... Thanks in advance! Rutuja --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: Question regarding the redirectsOn 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote:
> Hello, > > I am working on the application which fetches HTTP contents given the URL. > If there is any redirection from the original URL, I need to find out what's > the destination URL from which the contents are going to be fetched > eventually. Then depending on the predefined criterion I would like to > determine if the contents should be fetched from the final destination or > not. > > For example, when I use HttpClient to fetch contents from URL: > http://www.opensolaris.org/jive/login!withRedirect.jspa > > The request gets automatically redirected to > https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909 > and HttpClient returns the html contents from https://auth.opensolaris.... > > Based on the return code value from method.execute() call I have no way to > know that this happened. The return code is 200 (HttpStatus.SC_OK). > > I have two questions as follows: > 1> Is there any way to know that this redirect happened ? > 2> Can I control redirects completely? Meaning, is there any way to tell > HttpClient to not to fetch content from the new URL but just let the calling > method know what this new URL is? > > Please note setting method.followRedirects() to true or false did not alter > the behavior. Irrespective of setting this flag to false, the HTML contents > were fetched from https://auth.opensolaris.... Which version of HttpClient are you using? > Thanks in advance! > Rutuja > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > httpclient-users-unsubscribe@... > For additional commands, e-mail: > httpclient-users-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: Question regarding the redirectsHi Sebb,
Sorry to not mention it earlier. I am using HttpClient 3.1 (commons-httpclient-3.1.jar) Thanks, Rutuja sebb wrote: > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > >> Hello, >> >> I am working on the application which fetches HTTP contents given the URL. >> If there is any redirection from the original URL, I need to find out what's >> the destination URL from which the contents are going to be fetched >> eventually. Then depending on the predefined criterion I would like to >> determine if the contents should be fetched from the final destination or >> not. >> >> For example, when I use HttpClient to fetch contents from URL: >> http://www.opensolaris.org/jive/login!withRedirect.jspa >> >> The request gets automatically redirected to >> https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909 >> and HttpClient returns the html contents from https://auth.opensolaris.... >> >> Based on the return code value from method.execute() call I have no way to >> know that this happened. The return code is 200 (HttpStatus.SC_OK). >> >> I have two questions as follows: >> 1> Is there any way to know that this redirect happened ? >> 2> Can I control redirects completely? Meaning, is there any way to tell >> HttpClient to not to fetch content from the new URL but just let the calling >> method know what this new URL is? >> >> Please note setting method.followRedirects() to true or false did not alter >> the behavior. Irrespective of setting this flag to false, the HTML contents >> were fetched from https://auth.opensolaris.... >> > > Which version of HttpClient are you using? > > >> Thanks in advance! >> Rutuja >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: >> httpclient-users-unsubscribe@... >> For additional commands, e-mail: >> httpclient-users-help@... >> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > For additional commands, e-mail: httpclient-users-help@... > > |
|
|
Re: Question regarding the redirectsI just tried the URL using Apache JMeter 2.3.4 which uses HC 3.1, and
that shows the 304 Redirect response correctly, so long as one sets method.setFollowRedirects(false). Are you sure you are setting this correctly? On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > Hi Sebb, > > Sorry to not mention it earlier. I am using HttpClient 3.1 > (commons-httpclient-3.1.jar) > > Thanks, > Rutuja > > sebb wrote: > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > Hello, > > > > > > I am working on the application which fetches HTTP contents given the > URL. > > > If there is any redirection from the original URL, I need to find out > what's > > > the destination URL from which the contents are going to be fetched > > > eventually. Then depending on the predefined criterion I would like to > > > determine if the contents should be fetched from the final destination > or > > > not. > > > > > > For example, when I use HttpClient to fetch contents from URL: > > > > http://www.opensolaris.org/jive/login!withRedirect.jspa > > > > > > The request gets automatically redirected to > > > > https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909 > > > and HttpClient returns the html contents from > https://auth.opensolaris.... > > > > > > Based on the return code value from method.execute() call I have no way > to > > > know that this happened. The return code is 200 (HttpStatus.SC_OK). > > > > > > I have two questions as follows: > > > 1> Is there any way to know that this redirect happened ? > > > 2> Can I control redirects completely? Meaning, is there any way to > tell > > > HttpClient to not to fetch content from the new URL but just let the > calling > > > method know what this new URL is? > > > > > > Please note setting method.followRedirects() to true or false did not > alter > > > the behavior. Irrespective of setting this flag to false, the HTML > contents > > > were fetched from https://auth.opensolaris.... > > > > > > > > > > Which version of HttpClient are you using? > > > > > > > > > Thanks in advance! > > > Rutuja > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: > > > httpclient-users-unsubscribe@... > > > For additional commands, e-mail: > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > httpclient-users-unsubscribe@... > > For additional commands, e-mail: > httpclient-users-help@... > > > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: Question regarding the redirectsThanks Sebb!
I had actually commented out method.setFollowRedirects(true) in the code thinking that the default is false.When I explicitly set it to false, I get the response code as 302 ("HTTP/1.1 302 Moved Temporarily") and not 304. Is there any way to know what the new URL is going to be from the status line? Thanks, Rutuja sebb wrote: > I just tried the URL using Apache JMeter 2.3.4 which uses HC 3.1, and > that shows the 304 Redirect response correctly, so long as one sets > > method.setFollowRedirects(false). > > Are you sure you are setting this correctly? > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > >> Hi Sebb, >> >> Sorry to not mention it earlier. I am using HttpClient 3.1 >> (commons-httpclient-3.1.jar) >> >> Thanks, >> Rutuja >> >> sebb wrote: >> >> >>> On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: >>> >>> >>> >>>> Hello, >>>> >>>> I am working on the application which fetches HTTP contents given the >>>> >> URL. >> >>>> If there is any redirection from the original URL, I need to find out >>>> >> what's >> >>>> the destination URL from which the contents are going to be fetched >>>> eventually. Then depending on the predefined criterion I would like to >>>> determine if the contents should be fetched from the final destination >>>> >> or >> >>>> not. >>>> >>>> For example, when I use HttpClient to fetch contents from URL: >>>> >>>> >> http://www.opensolaris.org/jive/login!withRedirect.jspa >> >>>> The request gets automatically redirected to >>>> >>>> >> https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909 >> >>>> and HttpClient returns the html contents from >>>> >> https://auth.opensolaris.... >> >>>> Based on the return code value from method.execute() call I have no way >>>> >> to >> >>>> know that this happened. The return code is 200 (HttpStatus.SC_OK). >>>> >>>> I have two questions as follows: >>>> 1> Is there any way to know that this redirect happened ? >>>> 2> Can I control redirects completely? Meaning, is there any way to >>>> >> tell >> >>>> HttpClient to not to fetch content from the new URL but just let the >>>> >> calling >> >>>> method know what this new URL is? >>>> >>>> Please note setting method.followRedirects() to true or false did not >>>> >> alter >> >>>> the behavior. Irrespective of setting this flag to false, the HTML >>>> >> contents >> >>>> were fetched from https://auth.opensolaris.... >>>> >>>> >>>> >>> Which version of HttpClient are you using? >>> >>> >>> >>> >>>> Thanks in advance! >>>> Rutuja >>>> >>>> >>>> >>>> >> --------------------------------------------------------------------- >> >>>> To unsubscribe, e-mail: >>>> httpclient-users-unsubscribe@... >>>> For additional commands, e-mail: >>>> httpclient-users-help@... >>>> >>>> >>>> >>>> >>>> >>> >> --------------------------------------------------------------------- >> >>> To unsubscribe, e-mail: >>> >> httpclient-users-unsubscribe@... >> >>> For additional commands, e-mail: >>> >> httpclient-users-help@... >> >>> >>> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > For additional commands, e-mail: httpclient-users-help@... > > |
|
|
Re: Question regarding the redirectsOn 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote:
> Thanks Sebb! > > I had actually commented out > method.setFollowRedirects(true) in the code thinking that > the default is false.When I explicitly set it to false, I get the response > code as 302 ("HTTP/1.1 302 Moved Temporarily") and not 304. > > Is there any way to know what the new URL is going to be from the status > line? No. You need to look at the "Location" header. > Thanks, > Rutuja > > > sebb wrote: > > > > I just tried the URL using Apache JMeter 2.3.4 which uses HC 3.1, and > > that shows the 304 Redirect response correctly, so long as one sets > > > > method.setFollowRedirects(false). > > > > Are you sure you are setting this correctly? > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > Hi Sebb, > > > > > > Sorry to not mention it earlier. I am using HttpClient 3.1 > > > (commons-httpclient-3.1.jar) > > > > > > Thanks, > > > Rutuja > > > > > > sebb wrote: > > > > > > > > > > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > > > > > > > > > > > > > > > Hello, > > > > > > > > > > I am working on the application which fetches HTTP contents given > the > > > > > > > > > > > > > > > > > URL. > > > > > > > > > > > > > > > If there is any redirection from the original URL, I need to find > out > > > > > > > > > > > > > > > > > what's > > > > > > > > > > > > > > > the destination URL from which the contents are going to be fetched > > > > > eventually. Then depending on the predefined criterion I would like > to > > > > > determine if the contents should be fetched from the final > destination > > > > > > > > > > > > > > > > > or > > > > > > > > > > > > > > > not. > > > > > > > > > > For example, when I use HttpClient to fetch contents from URL: > > > > > > > > > > > > > > > > > > > > > > http://www.opensolaris.org/jive/login!withRedirect.jspa > > > > > > > > > > > > > > > The request gets automatically redirected to > > > > > > > > > > > > > > > > > > > > > > > https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909 > > > > > > > > > > > > > > > and HttpClient returns the html contents from > > > > > > > > > > > > > > > > > https://auth.opensolaris.... > > > > > > > > > > > > > > > Based on the return code value from method.execute() call I have no > way > > > > > > > > > > > > > > > > > to > > > > > > > > > > > > > > > know that this happened. The return code is 200 (HttpStatus.SC_OK). > > > > > > > > > > I have two questions as follows: > > > > > 1> Is there any way to know that this redirect happened ? > > > > > 2> Can I control redirects completely? Meaning, is there any way to > > > > > > > > > > > > > > > > > tell > > > > > > > > > > > > > > > HttpClient to not to fetch content from the new URL but just let the > > > > > > > > > > > > > > > > > calling > > > > > > > > > > > > > > > method know what this new URL is? > > > > > > > > > > Please note setting method.followRedirects() to true or false did > not > > > > > > > > > > > > > > > > > alter > > > > > > > > > > > > > > > the behavior. Irrespective of setting this flag to false, the HTML > > > > > > > > > > > > > > > > > contents > > > > > > > > > > > > > > > were fetched from https://auth.opensolaris.... > > > > > > > > > > > > > > > > > > > > > > > > Which version of HttpClient are you using? > > > > > > > > > > > > > > > > > > > > > > > > > Thanks in advance! > > > > > Rutuja > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > > > > > > To unsubscribe, e-mail: > > > > > httpclient-users-unsubscribe@... > > > > > For additional commands, e-mail: > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > To unsubscribe, e-mail: > > > > > > > > > > > httpclient-users-unsubscribe@... > > > > > > > > > > For additional commands, e-mail: > > > > > > > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > httpclient-users-unsubscribe@... > > For additional commands, e-mail: > httpclient-users-help@... > > > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: Question regarding the redirectsOn 08/09/2009, sebb <sebbaz@...> wrote:
> On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > Thanks Sebb! > > > > I had actually commented out > > method.setFollowRedirects(true) in the code thinking that > > the default is false.When I explicitly set it to false, I get the response > > code as 302 ("HTTP/1.1 302 Moved Temporarily") and not 304. Just double-checked and I got 302 (not 304); but the effect is much the same. > > > > Is there any way to know what the new URL is going to be from the status > > line? > > > No. > > You need to look at the "Location" header. > > > > Thanks, > > Rutuja > > > > > > sebb wrote: > > > > > > > I just tried the URL using Apache JMeter 2.3.4 which uses HC 3.1, and > > > that shows the 304 Redirect response correctly, so long as one sets > > > > > > method.setFollowRedirects(false). > > > > > > Are you sure you are setting this correctly? > > > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > > > > Hi Sebb, > > > > > > > > Sorry to not mention it earlier. I am using HttpClient 3.1 > > > > (commons-httpclient-3.1.jar) > > > > > > > > Thanks, > > > > Rutuja > > > > > > > > sebb wrote: > > > > > > > > > > > > > > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > Hello, > > > > > > > > > > > > I am working on the application which fetches HTTP contents given > > the > > > > > > > > > > > > > > > > > > > > > URL. > > > > > > > > > > > > > > > > > > > If there is any redirection from the original URL, I need to find > > out > > > > > > > > > > > > > > > > > > > > > what's > > > > > > > > > > > > > > > > > > > the destination URL from which the contents are going to be fetched > > > > > > eventually. Then depending on the predefined criterion I would like > > to > > > > > > determine if the contents should be fetched from the final > > destination > > > > > > > > > > > > > > > > > > > > > or > > > > > > > > > > > > > > > > > > > not. > > > > > > > > > > > > For example, when I use HttpClient to fetch contents from URL: > > > > > > > > > > > > > > > > > > > > > > > > > > > http://www.opensolaris.org/jive/login!withRedirect.jspa > > > > > > > > > > > > > > > > > > > The request gets automatically redirected to > > > > > > > > > > > > > > > > > > > > > > > > > > > > > https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909 > > > > > > > > > > > > > > > > > > > and HttpClient returns the html contents from > > > > > > > > > > > > > > > > > > > > > https://auth.opensolaris.... > > > > > > > > > > > > > > > > > > > Based on the return code value from method.execute() call I have no > > way > > > > > > > > > > > > > > > > > > > > > to > > > > > > > > > > > > > > > > > > > know that this happened. The return code is 200 (HttpStatus.SC_OK). > > > > > > > > > > > > I have two questions as follows: > > > > > > 1> Is there any way to know that this redirect happened ? > > > > > > 2> Can I control redirects completely? Meaning, is there any way to > > > > > > > > > > > > > > > > > > > > > tell > > > > > > > > > > > > > > > > > > > HttpClient to not to fetch content from the new URL but just let the > > > > > > > > > > > > > > > > > > > > > calling > > > > > > > > > > > > > > > > > > > method know what this new URL is? > > > > > > > > > > > > Please note setting method.followRedirects() to true or false did > > not > > > > > > > > > > > > > > > > > > > > > alter > > > > > > > > > > > > > > > > > > > the behavior. Irrespective of setting this flag to false, the HTML > > > > > > > > > > > > > > > > > > > > > contents > > > > > > > > > > > > > > > > > > > were fetched from https://auth.opensolaris.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Which version of HttpClient are you using? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks in advance! > > > > > > Rutuja > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > > > > > > > > > > To unsubscribe, e-mail: > > > > > > httpclient-users-unsubscribe@... > > > > > > For additional commands, e-mail: > > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > > > > To unsubscribe, e-mail: > > > > > > > > > > > > > > httpclient-users-unsubscribe@... > > > > > > > > > > > > > For additional commands, e-mail: > > > > > > > > > > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: > > httpclient-users-unsubscribe@... > > > For additional commands, e-mail: > > httpclient-users-help@... > > > > > > > > > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: Question regarding the redirectsThanks Sebb!
I tried reading Location header in my code. For URL http://www.opensolaris.org/jive/login!withRedirect.jspa, the contents are ultimately fetched from https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909. However, when I set method.setFollowRedirects(false), the location header says : "http://www.opensolaris.org//enter.jspa?targetPage=%2F" when I set method.setFollowRedirects(true) , the response headers do not have location header (may be as we allow HttpClient to follow the redirects) In short, I am not able to determine what the final URL would be based on the "Location" header. Am I missing something or it is not possible for HttpClient to keep track of the final destination URL. Thanks, Rutuja > On 08/09/2009, sebb <sebbaz@...> wrote: > >> On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: >> >> >>> Thanks Sebb! >>> >> > >> > I had actually commented out >> > method.setFollowRedirects(true) in the code thinking that >> > the default is false.When I explicitly set it to false, I get the response >> > code as 302 ("HTTP/1.1 302 Moved Temporarily") and not 304. >> > > Just double-checked and I got 302 (not 304); but the effect is much the same. > > >> > >> > Is there any way to know what the new URL is going to be from the status >> > line? >> >> >> No. >> >> You need to look at the "Location" header. >> >> >> > Thanks, >> > Rutuja >> > >> > >> > sebb wrote: >> > >> > >> > > I just tried the URL using Apache JMeter 2.3.4 which uses HC 3.1, and >> > > that shows the 304 Redirect response correctly, so long as one sets >> > > >> > > method.setFollowRedirects(false). >> > > >> > > Are you sure you are setting this correctly? >> > > >> > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: >> > > >> > > >> > > > Hi Sebb, >> > > > >> > > > Sorry to not mention it earlier. I am using HttpClient 3.1 >> > > > (commons-httpclient-3.1.jar) >> > > > >> > > > Thanks, >> > > > Rutuja >> > > > >> > > > sebb wrote: >> > > > >> > > > >> > > > >> > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: >> > > > > >> > > > > >> > > > > >> > > > > >> > > > > > Hello, >> > > > > > >> > > > > > I am working on the application which fetches HTTP contents given >> > the >> > > > > > >> > > > > > >> > > > > >> > > > URL. >> > > > >> > > > >> > > > > >> > > > > > If there is any redirection from the original URL, I need to find >> > out >> > > > > > >> > > > > > >> > > > > >> > > > what's >> > > > >> > > > >> > > > > >> > > > > > the destination URL from which the contents are going to be fetched >> > > > > > eventually. Then depending on the predefined criterion I would like >> > to >> > > > > > determine if the contents should be fetched from the final >> > destination >> > > > > > >> > > > > > >> > > > > >> > > > or >> > > > >> > > > >> > > > > >> > > > > > not. >> > > > > > >> > > > > > For example, when I use HttpClient to fetch contents from URL: >> > > > > > >> > > > > > >> > > > > > >> > > > > >> > > > http://www.opensolaris.org/jive/login!withRedirect.jspa >> > > > >> > > > >> > > > > >> > > > > > The request gets automatically redirected to >> > > > > > >> > > > > > >> > > > > > >> > > > > >> > > > >> > https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909 >> > > > >> > > > >> > > > > >> > > > > > and HttpClient returns the html contents from >> > > > > > >> > > > > > >> > > > > >> > > > https://auth.opensolaris.... >> > > > >> > > > >> > > > > >> > > > > > Based on the return code value from method.execute() call I have no >> > way >> > > > > > >> > > > > > >> > > > > >> > > > to >> > > > >> > > > >> > > > > >> > > > > > know that this happened. The return code is 200 (HttpStatus.SC_OK). >> > > > > > >> > > > > > I have two questions as follows: >> > > > > > 1> Is there any way to know that this redirect happened ? >> > > > > > 2> Can I control redirects completely? Meaning, is there any way to >> > > > > > >> > > > > > >> > > > > >> > > > tell >> > > > >> > > > >> > > > > >> > > > > > HttpClient to not to fetch content from the new URL but just let the >> > > > > > >> > > > > > >> > > > > >> > > > calling >> > > > >> > > > >> > > > > >> > > > > > method know what this new URL is? >> > > > > > >> > > > > > Please note setting method.followRedirects() to true or false did >> > not >> > > > > > >> > > > > > >> > > > > >> > > > alter >> > > > >> > > > >> > > > > >> > > > > > the behavior. Irrespective of setting this flag to false, the HTML >> > > > > > >> > > > > > >> > > > > >> > > > contents >> > > > >> > > > >> > > > > >> > > > > > were fetched from https://auth.opensolaris.... >> > > > > > >> > > > > > >> > > > > > >> > > > > > >> > > > > Which version of HttpClient are you using? >> > > > > >> > > > > >> > > > > >> > > > > >> > > > > >> > > > > > Thanks in advance! >> > > > > > Rutuja >> > > > > > >> > > > > > >> > > > > > >> > > > > > >> > > > > > >> > > > > >> > > > >> > --------------------------------------------------------------------- >> > > > >> > > > >> > > > > >> > > > > > To unsubscribe, e-mail: >> > > > > > httpclient-users-unsubscribe@... >> > > > > > For additional commands, e-mail: >> > > > > > httpclient-users-help@... >> > > > > > >> > > > > > >> > > > > > >> > > > > > >> > > > > > >> > > > > > >> > > > > >> > > > > >> > > > >> > --------------------------------------------------------------------- >> > > > >> > > > >> > > > > To unsubscribe, e-mail: >> > > > > >> > > > > >> > > > httpclient-users-unsubscribe@... >> > > > >> > > > >> > > > > For additional commands, e-mail: >> > > > > >> > > > > >> > > > httpclient-users-help@... >> > > > >> > > > >> > > > > >> > > > > >> > > > > >> > > > >> > > > >> > > >> > > >> > --------------------------------------------------------------------- >> > > To unsubscribe, e-mail: >> > httpclient-users-unsubscribe@... >> > > For additional commands, e-mail: >> > httpclient-users-help@... >> > > >> > > >> > > >> > >> > >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > For additional commands, e-mail: httpclient-users-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: Question regarding the redirectsThere are multiple redirects from the page you are beginning with.
Setting setFollowRedirects(false) means you will have to follow them all yourself. If you use wget you can see all the redirects: % wget -O /dev/null --no-check-certificate 'http://www.opensolaris.org/jive/login!withRedirect.jspa' --2009-09-08 16:15:35-- http://www.opensolaris.org/jive/login!withRedirect.jspa Resolving www.opensolaris.org... 72.5.123.5 Connecting to www.opensolaris.org|72.5.123.5|:80... connected. HTTP request sent, awaiting response... 302 Moved Temporarily Location: http://www.opensolaris.org//enter.jspa?targetPage=%2F [following] --2009-09-08 16:15:35-- http://www.opensolaris.org//enter.jspa?targetPage=%2F Reusing existing connection to www.opensolaris.org:80. HTTP request sent, awaiting response... 302 Moved Temporarily Location: https://www.opensolaris.org/enter.jspa?targetPage=%2F [following] --2009-09-08 16:15:35-- https://www.opensolaris.org/enter.jspa?targetPage=%2F Connecting to www.opensolaris.org|72.5.123.5|:443... connected. WARNING: cannot verify www.opensolaris.org's certificate, issued by `/O=Sun Microsystems Inc/OU=VeriSign Trust Network/OU=Class 3 MPKI Secure Server CA/CN=Sun Microsystems Inc SSL CA': Self-signed certificate encountered. HTTP request sent, awaiting response... 302 Moved Temporarily Location: https://auth.opensolaris.org/login.action?targetUrl=http://opensolaris.org/ [following] --2009-09-08 16:15:35-- https://auth.opensolaris.org/login.action?targetUrl=http://opensolaris.org/ Resolving auth.opensolaris.org... 72.5.123.23 Connecting to auth.opensolaris.org|72.5.123.23|:443... connected. WARNING: cannot verify auth.opensolaris.org's certificate, issued by `/O=Sun Microsystems Inc/OU=VeriSign Trust Network/OU=Class 3 MPKI Secure Server CA/CN=Sun Microsystems Inc SSL CA': Unable to locally verify the issuer's authority. HTTP request sent, awaiting response... 200 OK Length: 6695 (6.5K) [text/html] Saving to: `/dev/null' Rutuja Joshi wrote: > Thanks Sebb! > > I tried reading Location header in my code. > > For URL http://www.opensolaris.org/jive/login!withRedirect.jspa, the > contents are ultimately fetched from > https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909. > > > However, when I set method.setFollowRedirects(false), the location > header says : "http://www.opensolaris.org//enter.jspa?targetPage=%2F" > when I set method.setFollowRedirects(true) , the response headers do > not have location header (may be as we allow HttpClient to follow the > redirects) > > In short, I am not able to determine what the final URL would be based > on the "Location" header. Am I missing something or it is not possible > for HttpClient to keep track of the final destination URL. > > Thanks, > Rutuja > > >> On 08/09/2009, sebb <sebbaz@...> wrote: >> >>> On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: >>> >>> >>>> Thanks Sebb! >>>> >>> > >>> > I had actually commented out >>> > method.setFollowRedirects(true) in the code thinking that >>> > the default is false.When I explicitly set it to false, I get the >>> response >>> > code as 302 ("HTTP/1.1 302 Moved Temporarily") and not 304. >>> >> >> Just double-checked and I got 302 (not 304); but the effect is much >> the same. >> >> >>> > >>> > Is there any way to know what the new URL is going to be from >>> the status >>> > line? >>> >>> >>> No. >>> >>> You need to look at the "Location" header. >>> >>> >>> > Thanks, >>> > Rutuja >>> > >>> > >>> > sebb wrote: >>> > >>> > >>> > > I just tried the URL using Apache JMeter 2.3.4 which uses HC >>> 3.1, and >>> > > that shows the 304 Redirect response correctly, so long as one >>> sets >>> > > >>> > > method.setFollowRedirects(false). >>> > > >>> > > Are you sure you are setting this correctly? >>> > > >>> > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: >>> > > >>> > > >>> > > > Hi Sebb, >>> > > > >>> > > > Sorry to not mention it earlier. I am using HttpClient 3.1 >>> > > > (commons-httpclient-3.1.jar) >>> > > > >>> > > > Thanks, >>> > > > Rutuja >>> > > > >>> > > > sebb wrote: >>> > > > >>> > > > >>> > > > >>> > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: >>> > > > > >>> > > > > >>> > > > > >>> > > > > >>> > > > > > Hello, >>> > > > > > >>> > > > > > I am working on the application which fetches HTTP >>> contents given >>> > the >>> > > > > > >>> > > > > > >>> > > > > >>> > > > URL. >>> > > > >>> > > > >>> > > > > >>> > > > > > If there is any redirection from the original URL, I need >>> to find >>> > out >>> > > > > > >>> > > > > > >>> > > > > >>> > > > what's >>> > > > >>> > > > >>> > > > > >>> > > > > > the destination URL from which the contents are going to >>> be fetched >>> > > > > > eventually. Then depending on the predefined criterion I >>> would like >>> > to >>> > > > > > determine if the contents should be fetched from the final >>> > destination >>> > > > > > >>> > > > > > >>> > > > > >>> > > > or >>> > > > >>> > > > >>> > > > > >>> > > > > > not. >>> > > > > > >>> > > > > > For example, when I use HttpClient to fetch contents >>> from URL: >>> > > > > > >>> > > > > > >>> > > > > > >>> > > > > >>> > > > http://www.opensolaris.org/jive/login!withRedirect.jspa >>> > > > >>> > > > >>> > > > > >>> > > > > > The request gets automatically redirected to >>> > > > > > >>> > > > > > >>> > > > > > >>> > > > > >>> > > > >>> > >>> https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909 >>> >>> > > > >>> > > > >>> > > > > >>> > > > > > and HttpClient returns the html contents from >>> > > > > > >>> > > > > > >>> > > > > >>> > > > https://auth.opensolaris.... >>> > > > >>> > > > >>> > > > > >>> > > > > > Based on the return code value from method.execute() >>> call I have no >>> > way >>> > > > > > >>> > > > > > >>> > > > > >>> > > > to >>> > > > >>> > > > >>> > > > > >>> > > > > > know that this happened. The return code is 200 >>> (HttpStatus.SC_OK). >>> > > > > > >>> > > > > > I have two questions as follows: >>> > > > > > 1> Is there any way to know that this redirect happened ? >>> > > > > > 2> Can I control redirects completely? Meaning, is there >>> any way to >>> > > > > > >>> > > > > > >>> > > > > >>> > > > tell >>> > > > >>> > > > >>> > > > > >>> > > > > > HttpClient to not to fetch content from the new URL but >>> just let the >>> > > > > > >>> > > > > > >>> > > > > >>> > > > calling >>> > > > >>> > > > >>> > > > > >>> > > > > > method know what this new URL is? >>> > > > > > >>> > > > > > Please note setting method.followRedirects() to true or >>> false did >>> > not >>> > > > > > >>> > > > > > >>> > > > > >>> > > > alter >>> > > > >>> > > > >>> > > > > >>> > > > > > the behavior. Irrespective of setting this flag to false, >>> the HTML >>> > > > > > >>> > > > > > >>> > > > > >>> > > > contents >>> > > > >>> > > > >>> > > > > >>> > > > > > were fetched from https://auth.opensolaris.... >>> > > > > > >>> > > > > > >>> > > > > > >>> > > > > > >>> > > > > Which version of HttpClient are you using? >>> > > > > >>> > > > > >>> > > > > >>> > > > > >>> > > > > >>> > > > > > Thanks in advance! >>> > > > > > Rutuja >>> > > > > > >>> > > > > > >>> > > > > > >>> > > > > > >>> > > > > > >>> > > > > >>> > > > >>> > >>> --------------------------------------------------------------------- >>> > > > >>> > > > >>> > > > > >>> > > > > > To unsubscribe, e-mail: >>> > > > > > httpclient-users-unsubscribe@... >>> > > > > > For additional commands, e-mail: >>> > > > > > httpclient-users-help@... >>> > > > > > >>> > > > > > >>> > > > > > >>> > > > > > >>> > > > > > >>> > > > > > >>> > > > > >>> > > > > >>> > > > >>> > >>> --------------------------------------------------------------------- >>> > > > >>> > > > >>> > > > > To unsubscribe, e-mail: >>> > > > > >>> > > > > >>> > > > httpclient-users-unsubscribe@... >>> > > > >>> > > > >>> > > > > For additional commands, e-mail: >>> > > > > >>> > > > > >>> > > > httpclient-users-help@... >>> > > > >>> > > > >>> > > > > >>> > > > > >>> > > > > >>> > > > >>> > > > >>> > > >>> > > >>> > >>> --------------------------------------------------------------------- >>> > > To unsubscribe, e-mail: >>> > httpclient-users-unsubscribe@... >>> > > For additional commands, e-mail: >>> > httpclient-users-help@... >>> > > >>> > > >>> > > >>> > >>> > >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: httpclient-users-unsubscribe@... >> For additional commands, e-mail: httpclient-users-help@... >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > For additional commands, e-mail: httpclient-users-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: Question regarding the redirectsOn 09/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote:
> Thanks Sebb! > > I tried reading Location header in my code. > > For URL > http://www.opensolaris.org/jive/login!withRedirect.jspa, > the contents are ultimately fetched from > https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909. > > However, when I set method.setFollowRedirects(false), > the location header says : > "http://www.opensolaris.org//enter.jspa?targetPage=%2F" > when I set method.setFollowRedirects(true) , the response > headers do not have location header (may be as we allow HttpClient to follow > the redirects) > > In short, I am not able to determine what the final URL would be based on > the "Location" header. Am I missing something or it is not possible for > HttpClient to keep track of the final destination URL. httpMethod.getURI() will have the final URI. > Thanks, > Rutuja > > > > > > On 08/09/2009, sebb <sebbaz@...> wrote: > > > > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > > > > > > > Thanks Sebb! > > > > > > > > > > > > > > > > I had actually commented out > > > > method.setFollowRedirects(true) in the code thinking > that > > > > the default is false.When I explicitly set it to false, I get the > response > > > > code as 302 ("HTTP/1.1 302 Moved Temporarily") and not 304. > > > > > > > > > > Just double-checked and I got 302 (not 304); but the effect is much the > same. > > > > > > > > > > > > > > Is there any way to know what the new URL is going to be from the > status > > > > line? > > > > > > > > > No. > > > > > > You need to look at the "Location" header. > > > > > > > > > > Thanks, > > > > Rutuja > > > > > > > > > > > > sebb wrote: > > > > > > > > > > > > > I just tried the URL using Apache JMeter 2.3.4 which uses HC 3.1, > and > > > > > that shows the 304 Redirect response correctly, so long as one sets > > > > > > > > > > method.setFollowRedirects(false). > > > > > > > > > > Are you sure you are setting this correctly? > > > > > > > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > > > > > > > > > > Hi Sebb, > > > > > > > > > > > > Sorry to not mention it earlier. I am using HttpClient 3.1 > > > > > > (commons-httpclient-3.1.jar) > > > > > > > > > > > > Thanks, > > > > > > Rutuja > > > > > > > > > > > > sebb wrote: > > > > > > > > > > > > > > > > > > > > > > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hello, > > > > > > > > > > > > > > > > I am working on the application which fetches HTTP contents > given > > > > the > > > > > > > > > > > > > > > > > > > > > > > > > > > > > URL. > > > > > > > > > > > > > > > > > > > > > > > > > > > If there is any redirection from the original URL, I need to > find > > > > out > > > > > > > > > > > > > > > > > > > > > > > > > > > > > what's > > > > > > > > > > > > > > > > > > > > > > > > > > > the destination URL from which the contents are going to be > fetched > > > > > > > > eventually. Then depending on the predefined criterion I > would like > > > > to > > > > > > > > determine if the contents should be fetched from the final > > > > destination > > > > > > > > > > > > > > > > > > > > > > > > > > > > > or > > > > > > > > > > > > > > > > > > > > > > > > > > > not. > > > > > > > > > > > > > > > > For example, when I use HttpClient to fetch contents from > URL: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > http://www.opensolaris.org/jive/login!withRedirect.jspa > > > > > > > > > > > > > > > > > > > > > > > > > > > The request gets automatically redirected to > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909 > > > > > > > > > > > > > > > > > > > > > > > > > > > and HttpClient returns the html contents from > > > > > > > > > > > > > > > > > > > > > > > > > > > > > https://auth.opensolaris.... > > > > > > > > > > > > > > > > > > > > > > > > > > > Based on the return code value from method.execute() call I > have no > > > > way > > > > > > > > > > > > > > > > > > > > > > > > > > > > > to > > > > > > > > > > > > > > > > > > > > > > > > > > > know that this happened. The return code is 200 > (HttpStatus.SC_OK). > > > > > > > > > > > > > > > > I have two questions as follows: > > > > > > > > 1> Is there any way to know that this redirect happened ? > > > > > > > > 2> Can I control redirects completely? Meaning, is there any > way to > > > > > > > > > > > > > > > > > > > > > > > > > > > > > tell > > > > > > > > > > > > > > > > > > > > > > > > > > > HttpClient to not to fetch content from the new URL but just > let the > > > > > > > > > > > > > > > > > > > > > > > > > > > > > calling > > > > > > > > > > > > > > > > > > > > > > > > > > > method know what this new URL is? > > > > > > > > > > > > > > > > Please note setting method.followRedirects() to true or > false did > > > > not > > > > > > > > > > > > > > > > > > > > > > > > > > > > > alter > > > > > > > > > > > > > > > > > > > > > > > > > > > the behavior. Irrespective of setting this flag to false, the > HTML > > > > > > > > > > > > > > > > > > > > > > > > > > > > > contents > > > > > > > > > > > > > > > > > > > > > > > > > > > were fetched from https://auth.opensolaris.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Which version of HttpClient are you using? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks in advance! > > > > > > > > Rutuja > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > > > > > > > > > > > > > > > > > > To unsubscribe, e-mail: > > > > > > > > httpclient-users-unsubscribe@... > > > > > > > > For additional commands, e-mail: > > > > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > > > > > > > > > > To unsubscribe, e-mail: > > > > > > > > > > > > > > > > > > > > httpclient-users-unsubscribe@... > > > > > > > > > > > > > > > > > > > For additional commands, e-mail: > > > > > > > > > > > > > > > > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > To unsubscribe, e-mail: > > > > httpclient-users-unsubscribe@... > > > > > For additional commands, e-mail: > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > httpclient-users-unsubscribe@... > > For additional commands, e-mail: > httpclient-users-help@... > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > httpclient-users-unsubscribe@... > For additional commands, e-mail: > httpclient-users-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: Question regarding the redirectsHi sebb,
httpMethod.getURI() gives the URL as http://www.opensolaris.org/jive/login!withRedirect.jspa, so basically its the URL that this method tired to connect to and received a 302 response. I was hoping to get https://auth.opensolaris.org/... in the form of some header somewhere. As Joseph suggested, I have option of handling series of redirects manually and that way I will know what URL is the final URL. I will try that but just confirming that there is no other simpler way to know the final destination URL . Thanks a lot for your responses. Rutuja sebb wrote: > On 09/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > >> Thanks Sebb! >> >> I tried reading Location header in my code. >> >> For URL >> http://www.opensolaris.org/jive/login!withRedirect.jspa, >> the contents are ultimately fetched from >> https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909. >> >> However, when I set method.setFollowRedirects(false), >> the location header says : >> "http://www.opensolaris.org//enter.jspa?targetPage=%2F" >> when I set method.setFollowRedirects(true) , the response >> headers do not have location header (may be as we allow HttpClient to follow >> the redirects) >> >> In short, I am not able to determine what the final URL would be based on >> the "Location" header. Am I missing something or it is not possible for >> HttpClient to keep track of the final destination URL. >> > > httpMethod.getURI() will have the final URI. > > >> Thanks, >> Rutuja >> >> >> >> >> >>> On 08/09/2009, sebb <sebbaz@...> wrote: >>> >>> >>> >>>> On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: >>>> >>>> >>>> >>>> >>>>> Thanks Sebb! >>>>> >>>>> >>>>> >>>> > >>>> > I had actually commented out >>>> > method.setFollowRedirects(true) in the code thinking >>>> >> that >> >>>> > the default is false.When I explicitly set it to false, I get the >>>> >> response >> >>>> > code as 302 ("HTTP/1.1 302 Moved Temporarily") and not 304. >>>> >>>> >>>> >>> Just double-checked and I got 302 (not 304); but the effect is much the >>> >> same. >> >>> >>> >>>> > >>>> > Is there any way to know what the new URL is going to be from the >>>> >> status >> >>>> > line? >>>> >>>> >>>> No. >>>> >>>> You need to look at the "Location" header. >>>> >>>> >>>> > Thanks, >>>> > Rutuja >>>> > >>>> > >>>> > sebb wrote: >>>> > >>>> > >>>> > > I just tried the URL using Apache JMeter 2.3.4 which uses HC 3.1, >>>> >> and >> >>>> > > that shows the 304 Redirect response correctly, so long as one sets >>>> > > >>>> > > method.setFollowRedirects(false). >>>> > > >>>> > > Are you sure you are setting this correctly? >>>> > > >>>> > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: >>>> > > >>>> > > >>>> > > > Hi Sebb, >>>> > > > >>>> > > > Sorry to not mention it earlier. I am using HttpClient 3.1 >>>> > > > (commons-httpclient-3.1.jar) >>>> > > > >>>> > > > Thanks, >>>> > > > Rutuja >>>> > > > >>>> > > > sebb wrote: >>>> > > > >>>> > > > >>>> > > > >>>> > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: >>>> > > > > >>>> > > > > >>>> > > > > >>>> > > > > >>>> > > > > > Hello, >>>> > > > > > >>>> > > > > > I am working on the application which fetches HTTP contents >>>> >> given >> >>>> > the >>>> > > > > > >>>> > > > > > >>>> > > > > >>>> > > > URL. >>>> > > > >>>> > > > >>>> > > > > >>>> > > > > > If there is any redirection from the original URL, I need to >>>> >> find >> >>>> > out >>>> > > > > > >>>> > > > > > >>>> > > > > >>>> > > > what's >>>> > > > >>>> > > > >>>> > > > > >>>> > > > > > the destination URL from which the contents are going to be >>>> >> fetched >> >>>> > > > > > eventually. Then depending on the predefined criterion I >>>> >> would like >> >>>> > to >>>> > > > > > determine if the contents should be fetched from the final >>>> > destination >>>> > > > > > >>>> > > > > > >>>> > > > > >>>> > > > or >>>> > > > >>>> > > > >>>> > > > > >>>> > > > > > not. >>>> > > > > > >>>> > > > > > For example, when I use HttpClient to fetch contents from >>>> >> URL: >> >>>> > > > > > >>>> > > > > > >>>> > > > > > >>>> > > > > >>>> > > > >>>> >> http://www.opensolaris.org/jive/login!withRedirect.jspa >> >>>> > > > >>>> > > > >>>> > > > > >>>> > > > > > The request gets automatically redirected to >>>> > > > > > >>>> > > > > > >>>> > > > > > >>>> > > > > >>>> > > > >>>> > >>>> >> https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909 >> >>>> > > > >>>> > > > >>>> > > > > >>>> > > > > > and HttpClient returns the html contents from >>>> > > > > > >>>> > > > > > >>>> > > > > >>>> > > > https://auth.opensolaris.... >>>> > > > >>>> > > > >>>> > > > > >>>> > > > > > Based on the return code value from method.execute() call I >>>> >> have no >> >>>> > way >>>> > > > > > >>>> > > > > > >>>> > > > > >>>> > > > to >>>> > > > >>>> > > > >>>> > > > > >>>> > > > > > know that this happened. The return code is 200 >>>> >> (HttpStatus.SC_OK). >> >>>> > > > > > >>>> > > > > > I have two questions as follows: >>>> > > > > > 1> Is there any way to know that this redirect happened ? >>>> > > > > > 2> Can I control redirects completely? Meaning, is there any >>>> >> way to >> >>>> > > > > > >>>> > > > > > >>>> > > > > >>>> > > > tell >>>> > > > >>>> > > > >>>> > > > > >>>> > > > > > HttpClient to not to fetch content from the new URL but just >>>> >> let the >> >>>> > > > > > >>>> > > > > > >>>> > > > > >>>> > > > calling >>>> > > > >>>> > > > >>>> > > > > >>>> > > > > > method know what this new URL is? >>>> > > > > > >>>> > > > > > Please note setting method.followRedirects() to true or >>>> >> false did >> >>>> > not >>>> > > > > > >>>> > > > > > >>>> > > > > >>>> > > > alter >>>> > > > >>>> > > > >>>> > > > > >>>> > > > > > the behavior. Irrespective of setting this flag to false, the >>>> >> HTML >> >>>> > > > > > >>>> > > > > > >>>> > > > > >>>> > > > contents >>>> > > > >>>> > > > >>>> > > > > >>>> > > > > > were fetched from https://auth.opensolaris.... >>>> > > > > > >>>> > > > > > >>>> > > > > > >>>> > > > > > >>>> > > > > Which version of HttpClient are you using? >>>> > > > > >>>> > > > > >>>> > > > > >>>> > > > > >>>> > > > > >>>> > > > > > Thanks in advance! >>>> > > > > > Rutuja >>>> > > > > > >>>> > > > > > >>>> > > > > > >>>> > > > > > >>>> > > > > > >>>> > > > > >>>> > > > >>>> > >>>> >> --------------------------------------------------------------------- >> >>>> > > > >>>> > > > >>>> > > > > >>>> > > > > > To unsubscribe, e-mail: >>>> > > > > > httpclient-users-unsubscribe@... >>>> > > > > > For additional commands, e-mail: >>>> > > > > > httpclient-users-help@... >>>> > > > > > >>>> > > > > > >>>> > > > > > >>>> > > > > > >>>> > > > > > >>>> > > > > > >>>> > > > > >>>> > > > > >>>> > > > >>>> > >>>> >> --------------------------------------------------------------------- >> >>>> > > > >>>> > > > >>>> > > > > To unsubscribe, e-mail: >>>> > > > > >>>> > > > > >>>> > > > httpclient-users-unsubscribe@... >>>> > > > >>>> > > > >>>> > > > > For additional commands, e-mail: >>>> > > > > >>>> > > > > >>>> > > > httpclient-users-help@... >>>> > > > >>>> > > > >>>> > > > > >>>> > > > > >>>> > > > > >>>> > > > >>>> > > > >>>> > > >>>> > > >>>> > >>>> >> --------------------------------------------------------------------- >> >>>> > > To unsubscribe, e-mail: >>>> > httpclient-users-unsubscribe@... >>>> > > For additional commands, e-mail: >>>> > httpclient-users-help@... >>>> > > >>>> > > >>>> > > >>>> > >>>> > >>>> >>>> >>>> >>>> >>> >> --------------------------------------------------------------------- >> >>> To unsubscribe, e-mail: >>> >> httpclient-users-unsubscribe@... >> >>> For additional commands, e-mail: >>> >> httpclient-users-help@... >> >>> >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: >> httpclient-users-unsubscribe@... >> For additional commands, e-mail: >> httpclient-users-help@... >> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > For additional commands, e-mail: httpclient-users-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: Question regarding the redirectsOn 09/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote:
> Hi sebb, > > httpMethod.getURI() gives the URL as > http://www.opensolaris.org/jive/login!withRedirect.jspa, so > basically its the URL that this method tired to connect to and received a > 302 response. I was hoping to get > https://auth.opensolaris.org/... in the form of some header > somewhere. Works for me. > As Joseph suggested, I have option of handling series of redirects manually > and that way I will know what URL is the final URL. I will try that but just > confirming that there is no other simpler way to know the final destination > URL . > > Thanks a lot for your responses. > Rutuja > > > sebb wrote: > > > On 09/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > Thanks Sebb! > > > > > > I tried reading Location header in my code. > > > > > > For URL > > > > http://www.opensolaris.org/jive/login!withRedirect.jspa, > > > the contents are ultimately fetched from > > > > https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909. > > > > > > However, when I set method.setFollowRedirects(false), > > > the location header says : > > > "http://www.opensolaris.org//enter.jspa?targetPage=%2F" > > > when I set method.setFollowRedirects(true) , the > response > > > headers do not have location header (may be as we allow HttpClient to > follow > > > the redirects) > > > > > > In short, I am not able to determine what the final URL would be based > on > > > the "Location" header. Am I missing something or it is not possible for > > > HttpClient to keep track of the final destination URL. > > > > > > > > > > httpMethod.getURI() will have the final URI. > > > > > > > > > Thanks, > > > Rutuja > > > > > > > > > > > > > > > > > > > > > > On 08/09/2009, sebb <sebbaz@...> wrote: > > > > > > > > > > > > > > > > > > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks Sebb! > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I had actually commented out > > > > > > method.setFollowRedirects(true) in the code > thinking > > > > > > > > > > > > > > > > > that > > > > > > > > > > > > > > > > the default is false.When I explicitly set it to false, I get the > > > > > > > > > > > > > > > > > response > > > > > > > > > > > > > > > > code as 302 ("HTTP/1.1 302 Moved Temporarily") and not 304. > > > > > > > > > > > > > > > > > > > > > > > > Just double-checked and I got 302 (not 304); but the effect is much > the > > > > > > > > > > > same. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Is there any way to know what the new URL is going to be from > the > > > > > > > > > > > > > > > > > status > > > > > > > > > > > > > > > > line? > > > > > > > > > > > > > > > No. > > > > > > > > > > You need to look at the "Location" header. > > > > > > > > > > > > > > > > Thanks, > > > > > > Rutuja > > > > > > > > > > > > > > > > > > sebb wrote: > > > > > > > > > > > > > > > > > > > I just tried the URL using Apache JMeter 2.3.4 which uses HC > 3.1, > > > > > > > > > > > > > > > > > and > > > > > > > > > > > > > > > > > that shows the 304 Redirect response correctly, so long as one > sets > > > > > > > > > > > > > > method.setFollowRedirects(false). > > > > > > > > > > > > > > Are you sure you are setting this correctly? > > > > > > > > > > > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > > > > > > > > > > > > > > > > Hi Sebb, > > > > > > > > > > > > > > > > Sorry to not mention it earlier. I am using HttpClient 3.1 > > > > > > > > (commons-httpclient-3.1.jar) > > > > > > > > > > > > > > > > Thanks, > > > > > > > > Rutuja > > > > > > > > > > > > > > > > sebb wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hello, > > > > > > > > > > > > > > > > > > > > I am working on the application which fetches HTTP > contents > > > > > > > > > > > > > > > > > given > > > > > > > > > > > > > > > > the > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > URL. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > If there is any redirection from the original URL, I need > to > > > > > > > > > > > > > > > > > find > > > > > > > > > > > > > > > > out > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > what's > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > the destination URL from which the contents are going to > be > > > > > > > > > > > > > > > > > fetched > > > > > > > > > > > > > > > > > > > > eventually. Then depending on the predefined criterion I > > > > > > > > > > > > > > > > > would like > > > > > > > > > > > > > > > > to > > > > > > > > > > determine if the contents should be fetched from the > final > > > > > > destination > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > or > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > not. > > > > > > > > > > > > > > > > > > > > For example, when I use HttpClient to fetch contents > from > > > > > > > > > > > > > > > > > URL: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > http://www.opensolaris.org/jive/login!withRedirect.jspa > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > The request gets automatically redirected to > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > and HttpClient returns the html contents from > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > https://auth.opensolaris.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Based on the return code value from method.execute() > call I > > > > > > > > > > > > > > > > > have no > > > > > > > > > > > > > > > > way > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > to > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > know that this happened. The return code is 200 > > > > > > > > > > > > > > > > > (HttpStatus.SC_OK). > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I have two questions as follows: > > > > > > > > > > 1> Is there any way to know that this redirect happened > ? > > > > > > > > > > 2> Can I control redirects completely? Meaning, is there > any > > > > > > > > > > > > > > > > > way to > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > tell > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > HttpClient to not to fetch content from the new URL but > just > > > > > > > > > > > > > > > > > let the > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > calling > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > method know what this new URL is? > > > > > > > > > > > > > > > > > > > > Please note setting method.followRedirects() to true or > > > > > > > > > > > > > > > > > false did > > > > > > > > > > > > > > > > not > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > alter > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > the behavior. Irrespective of setting this flag to false, > the > > > > > > > > > > > > > > > > > HTML > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > contents > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > were fetched from https://auth.opensolaris.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Which version of HttpClient are you using? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks in advance! > > > > > > > > > > Rutuja > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > To unsubscribe, e-mail: > > > > > > > > > > > httpclient-users-unsubscribe@... > > > > > > > > > > For additional commands, e-mail: > > > > > > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > To unsubscribe, e-mail: > > > > > > > > > > > > > > > > > > > > > > > > > > httpclient-users-unsubscribe@... > > > > > > > > > > > > > > > > > > > > > > > > > For additional commands, e-mail: > > > > > > > > > > > > > > > > > > > > > > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > > > > > > > > To unsubscribe, e-mail: > > > > > > httpclient-users-unsubscribe@... > > > > > > > For additional commands, e-mail: > > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > To unsubscribe, e-mail: > > > > > > > > > > > httpclient-users-unsubscribe@... > > > > > > > > > > For additional commands, e-mail: > > > > > > > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: > > > httpclient-users-unsubscribe@... > > > For additional commands, e-mail: > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > httpclient-users-unsubscribe@... > > For additional commands, e-mail: > httpclient-users-help@... > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > httpclient-users-unsubscribe@... > For additional commands, e-mail: > httpclient-users-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
|
|
Re: Question regarding the redirectsHi Sebb,
getURI() function returns final URL as https://auth.opensolaris.org/... when setFollowRedirects is set to true. The problem is that I do not want to go fetch or rather my application is * not supposed * to fetch the contents from this URL so I have to set it to false. When I set it to false the getURI() does not return final URL as https://auth.opensolaris.org/...which is correct as I HttpClient never went to this URL. Basically, the solution looks like handling redirects manually. If you could suggest any other way then please let me know, Thanks a lot, Rutuja sebb wrote: > On 09/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > >> Hi sebb, >> >> httpMethod.getURI() gives the URL as >> http://www.opensolaris.org/jive/login!withRedirect.jspa, so >> basically its the URL that this method tired to connect to and received a >> 302 response. I was hoping to get >> https://auth.opensolaris.org/... in the form of some header >> somewhere. >> > > Works for me. > > >> As Joseph suggested, I have option of handling series of redirects manually >> and that way I will know what URL is the final URL. I will try that but just >> confirming that there is no other simpler way to know the final destination >> URL . >> >> Thanks a lot for your responses. >> Rutuja >> >> >> sebb wrote: >> >> >>> On 09/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: >>> >>> >>> >>>> Thanks Sebb! >>>> >>>> I tried reading Location header in my code. >>>> >>>> For URL >>>> >>>> >> http://www.opensolaris.org/jive/login!withRedirect.jspa, >> >>>> the contents are ultimately fetched from >>>> >>>> >> https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909. >> >>>> However, when I set method.setFollowRedirects(false), >>>> the location header says : >>>> "http://www.opensolaris.org//enter.jspa?targetPage=%2F" >>>> when I set method.setFollowRedirects(true) , the >>>> >> response >> >>>> headers do not have location header (may be as we allow HttpClient to >>>> >> follow >> >>>> the redirects) >>>> >>>> In short, I am not able to determine what the final URL would be based >>>> >> on >> >>>> the "Location" header. Am I missing something or it is not possible for >>>> HttpClient to keep track of the final destination URL. >>>> >>>> >>>> >>> httpMethod.getURI() will have the final URI. >>> >>> >>> >>> >>>> Thanks, >>>> Rutuja >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>>> On 08/09/2009, sebb <sebbaz@...> wrote: >>>>> >>>>> >>>>> >>>>> >>>>> >>>>>> On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>>> Thanks Sebb! >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> > >>>>>> > I had actually commented out >>>>>> > method.setFollowRedirects(true) in the code >>>>>> >> thinking >> >>>>>> >>>> that >>>> >>>> >>>> >>>>>> > the default is false.When I explicitly set it to false, I get the >>>>>> >>>>>> >>>>>> >>>> response >>>> >>>> >>>> >>>>>> > code as 302 ("HTTP/1.1 302 Moved Temporarily") and not 304. >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>> Just double-checked and I got 302 (not 304); but the effect is much >>>>> >> the >> >>>>> >>>> same. >>>> >>>> >>>> >>>>> >>>>> >>>>>> > >>>>>> > Is there any way to know what the new URL is going to be from >>>>>> >> the >> >>>>>> >>>> status >>>> >>>> >>>> >>>>>> > line? >>>>>> >>>>>> >>>>>> No. >>>>>> >>>>>> You need to look at the "Location" header. >>>>>> >>>>>> >>>>>> > Thanks, >>>>>> > Rutuja >>>>>> > >>>>>> > >>>>>> > sebb wrote: >>>>>> > >>>>>> > >>>>>> > > I just tried the URL using Apache JMeter 2.3.4 which uses HC >>>>>> >> 3.1, >> >>>>>> >>>> and >>>> >>>> >>>> >>>>>> > > that shows the 304 Redirect response correctly, so long as one >>>>>> >> sets >> >>>>>> > > >>>>>> > > method.setFollowRedirects(false). >>>>>> > > >>>>>> > > Are you sure you are setting this correctly? >>>>>> > > >>>>>> > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: >>>>>> > > >>>>>> > > >>>>>> > > > Hi Sebb, >>>>>> > > > >>>>>> > > > Sorry to not mention it earlier. I am using HttpClient 3.1 >>>>>> > > > (commons-httpclient-3.1.jar) >>>>>> > > > >>>>>> > > > Thanks, >>>>>> > > > Rutuja >>>>>> > > > >>>>>> > > > sebb wrote: >>>>>> > > > >>>>>> > > > >>>>>> > > > >>>>>> > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: >>>>>> > > > > >>>>>> > > > > >>>>>> > > > > >>>>>> > > > > >>>>>> > > > > > Hello, >>>>>> > > > > > >>>>>> > > > > > I am working on the application which fetches HTTP >>>>>> >> contents >> >>>>>> >>>> given >>>> >>>> >>>> >>>>>> > the >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > >>>>>> > > > URL. >>>>>> > > > >>>>>> > > > >>>>>> > > > > >>>>>> > > > > > If there is any redirection from the original URL, I need >>>>>> >> to >> >>>>>> >>>> find >>>> >>>> >>>> >>>>>> > out >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > >>>>>> > > > what's >>>>>> > > > >>>>>> > > > >>>>>> > > > > >>>>>> > > > > > the destination URL from which the contents are going to >>>>>> >> be >> >>>>>> >>>> fetched >>>> >>>> >>>> >>>>>> > > > > > eventually. Then depending on the predefined criterion I >>>>>> >>>>>> >>>>>> >>>> would like >>>> >>>> >>>> >>>>>> > to >>>>>> > > > > > determine if the contents should be fetched from the >>>>>> >> final >> >>>>>> > destination >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > >>>>>> > > > or >>>>>> > > > >>>>>> > > > >>>>>> > > > > >>>>>> > > > > > not. >>>>>> > > > > > >>>>>> > > > > > For example, when I use HttpClient to fetch contents >>>>>> >> from >> >>>>>> >>>> URL: >>>> >>>> >>>> >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > >>>>>> > > > >>>>>> >>>>>> >>>>>> >>>> http://www.opensolaris.org/jive/login!withRedirect.jspa >>>> >>>> >>>> >>>>>> > > > >>>>>> > > > >>>>>> > > > > >>>>>> > > > > > The request gets automatically redirected to >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > >>>>>> > > > >>>>>> > >>>>>> >>>>>> >>>>>> >> https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909 >> >>>> >>>>>> > > > >>>>>> > > > >>>>>> > > > > >>>>>> > > > > > and HttpClient returns the html contents from >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > >>>>>> > > > https://auth.opensolaris.... >>>>>> > > > >>>>>> > > > >>>>>> > > > > >>>>>> > > > > > Based on the return code value from method.execute() >>>>>> >> call I >> >>>>>> >>>> have no >>>> >>>> >>>> >>>>>> > way >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > >>>>>> > > > to >>>>>> > > > >>>>>> > > > >>>>>> > > > > >>>>>> > > > > > know that this happened. The return code is 200 >>>>>> >>>>>> >>>>>> >>>> (HttpStatus.SC_OK). >>>> >>>> >>>> >>>>>> > > > > > >>>>>> > > > > > I have two questions as follows: >>>>>> > > > > > 1> Is there any way to know that this redirect happened >>>>>> >> ? >> >>>>>> > > > > > 2> Can I control redirects completely? Meaning, is there >>>>>> >> any >> >>>>>> >>>> way to >>>> >>>> >>>> >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > >>>>>> > > > tell >>>>>> > > > >>>>>> > > > >>>>>> > > > > >>>>>> > > > > > HttpClient to not to fetch content from the new URL but >>>>>> >> just >> >>>>>> >>>> let the >>>> >>>> >>>> >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > >>>>>> > > > calling >>>>>> > > > >>>>>> > > > >>>>>> > > > > >>>>>> > > > > > method know what this new URL is? >>>>>> > > > > > >>>>>> > > > > > Please note setting method.followRedirects() to true or >>>>>> >>>>>> >>>>>> >>>> false did >>>> >>>> >>>> >>>>>> > not >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > >>>>>> > > > alter >>>>>> > > > >>>>>> > > > >>>>>> > > > > >>>>>> > > > > > the behavior. Irrespective of setting this flag to false, >>>>>> >> the >> >>>>>> >>>> HTML >>>> >>>> >>>> >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > >>>>>> > > > contents >>>>>> > > > >>>>>> > > > >>>>>> > > > > >>>>>> > > > > > were fetched from https://auth.opensolaris.... >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > Which version of HttpClient are you using? >>>>>> > > > > >>>>>> > > > > >>>>>> > > > > >>>>>> > > > > >>>>>> > > > > >>>>>> > > > > > Thanks in advance! >>>>>> > > > > > Rutuja >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > >>>>>> > > > >>>>>> > >>>>>> >>>>>> >>>>>> >> --------------------------------------------------------------------- >> >>>> >>>>>> > > > >>>>>> > > > >>>>>> > > > > >>>>>> > > > > > To unsubscribe, e-mail: >>>>>> > > > > > >>>>>> >> httpclient-users-unsubscribe@... >> >>>>>> > > > > > For additional commands, e-mail: >>>>>> > > > > > httpclient-users-help@... >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > > >>>>>> > > > > >>>>>> > > > > >>>>>> > > > >>>>>> > >>>>>> >>>>>> >>>>>> >> --------------------------------------------------------------------- >> >>>> >>>>>> > > > >>>>>> > > > >>>>>> > > > > To unsubscribe, e-mail: >>>>>> > > > > >>>>>> > > > > >>>>>> > > > httpclient-users-unsubscribe@... >>>>>> > > > >>>>>> > > > >>>>>> > > > > For additional commands, e-mail: >>>>>> > > > > >>>>>> > > > > >>>>>> > > > httpclient-users-help@... >>>>>> > > > >>>>>> > > > >>>>>> > > > > >>>>>> > > > > >>>>>> > > > > >>>>>> > > > >>>>>> > > > >>>>>> > > >>>>>> > > >>>>>> > >>>>>> >>>>>> >>>>>> >> --------------------------------------------------------------------- >> >>>> >>>>>> > > To unsubscribe, e-mail: >>>>>> > httpclient-users-unsubscribe@... >>>>>> > > For additional commands, e-mail: >>>>>> > httpclient-users-help@... >>>>>> > > >>>>>> > > >>>>>> > > >>>>>> > >>>>>> > >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>> >> --------------------------------------------------------------------- >> >>>> >>>>> To unsubscribe, e-mail: >>>>> >>>>> >>>>> >>>> httpclient-users-unsubscribe@... >>>> >>>> >>>> >>>>> For additional commands, e-mail: >>>>> >>>>> >>>>> >>>> httpclient-users-help@... >>>> >>>> >>>> >>>>> >>>>> >> --------------------------------------------------------------------- >> >>>> To unsubscribe, e-mail: >>>> httpclient-users-unsubscribe@... >>>> For additional commands, e-mail: >>>> httpclient-users-help@... >>>> >>>> >>>> >>>> >>>> >>> >> --------------------------------------------------------------------- >> >>> To unsubscribe, e-mail: >>> >> httpclient-users-unsubscribe@... >> >>> For additional commands, e-mail: >>> >> httpclient-users-help@... >> >>> >>> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: >> httpclient-users-unsubscribe@... >> For additional commands, e-mail: >> httpclient-users-help@... >> >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@... > For additional commands, e-mail: httpclient-users-help@... > > |
|
|
Re: Question regarding the redirectsOn 09/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote:
> Hi Sebb, > > getURI() function returns final URL as > https://auth.opensolaris.org/... when setFollowRedirects is > set to true. The problem is that I do not want to go fetch or rather my > application is * not supposed * to fetch the contents from this URL so I > have to set it to false. When I set it to false the getURI() does not return > final URL as https://auth.opensolaris.org/...which is > correct as I HttpClient never went to this URL. > > Basically, the solution looks like handling redirects manually. If you > could suggest any other way then please let me know, As far as I can tell, what you are trying to do is to follow all the redirects apart from the last one. In which case, you will have to do this yourself, as only you know when to stop. > Thanks a lot, > Rutuja > > > > sebb wrote: > > > On 09/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > Hi sebb, > > > > > > httpMethod.getURI() gives the URL as > > > > http://www.opensolaris.org/jive/login!withRedirect.jspa, so > > > basically its the URL that this method tired to connect to and received > a > > > 302 response. I was hoping to get > > > https://auth.opensolaris.org/... in the form of some > header > > > somewhere. > > > > > > > > > > Works for me. > > > > > > > > > As Joseph suggested, I have option of handling series of redirects > manually > > > and that way I will know what URL is the final URL. I will try that but > just > > > confirming that there is no other simpler way to know the final > destination > > > URL . > > > > > > Thanks a lot for your responses. > > > Rutuja > > > > > > > > > sebb wrote: > > > > > > > > > > > > > On 09/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > > > > > > > > > > > > > > > Thanks Sebb! > > > > > > > > > > I tried reading Location header in my code. > > > > > > > > > > For URL > > > > > > > > > > > > > > > > > > > > > > > http://www.opensolaris.org/jive/login!withRedirect.jspa, > > > > > > > > > > > > > > > the contents are ultimately fetched from > > > > > > > > > > > > > > > > > > > > > > > https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909. > > > > > > > > > > > > > > > However, when I set > method.setFollowRedirects(false), > > > > > the location header says : > > > > > > "http://www.opensolaris.org//enter.jspa?targetPage=%2F" > > > > > when I set method.setFollowRedirects(true) , the > > > > > > > > > > > > > > > > > response > > > > > > > > > > > > > > > headers do not have location header (may be as we allow HttpClient > to > > > > > > > > > > > > > > > > > follow > > > > > > > > > > > > > > > the redirects) > > > > > > > > > > In short, I am not able to determine what the final URL would be > based > > > > > > > > > > > > > > > > > on > > > > > > > > > > > > > > > the "Location" header. Am I missing something or it is not possible > for > > > > > HttpClient to keep track of the final destination URL. > > > > > > > > > > > > > > > > > > > > > > > > httpMethod.getURI() will have the final URI. > > > > > > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > Rutuja > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On 08/09/2009, sebb <sebbaz@...> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks Sebb! > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I had actually commented out > > > > > > > > method.setFollowRedirects(true) in the code > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > thinking > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > that > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > the default is false.When I explicitly set it to false, I get > the > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > response > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > code as 302 ("HTTP/1.1 302 Moved Temporarily") and not 304. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Just double-checked and I got 302 (not 304); but the effect is > much > > > > > > > > > > > > > > > > > > > > > > > > the > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > same. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Is there any way to know what the new URL is going to be > from > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > the > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > status > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > line? > > > > > > > > > > > > > > > > > > > > > No. > > > > > > > > > > > > > > You need to look at the "Location" header. > > > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > Rutuja > > > > > > > > > > > > > > > > > > > > > > > > sebb wrote: > > > > > > > > > > > > > > > > > > > > > > > > > I just tried the URL using Apache JMeter 2.3.4 which uses > HC > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 3.1, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > and > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > that shows the 304 Redirect response correctly, so long as > one > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > sets > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > method.setFollowRedirects(false). > > > > > > > > > > > > > > > > > > Are you sure you are setting this correctly? > > > > > > > > > > > > > > > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi Sebb, > > > > > > > > > > > > > > > > > > > > Sorry to not mention it earlier. I am using HttpClient > 3.1 > > > > > > > > > > (commons-httpclient-3.1.jar) > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > Rutuja > > > > > > > > > > > > > > > > > > > > sebb wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On 08/09/2009, Rutuja Joshi <Rutuja.Joshi@...> > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hello, > > > > > > > > > > > > > > > > > > > > > > > > I am working on the application which fetches HTTP > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > contents > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > given > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > the > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > URL. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > If there is any redirection from the original URL, I > need > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > to > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > find > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > out > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > what's > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > the destination URL from which the contents are going > to > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > be > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > fetched > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > eventually. Then depending on the predefined > criterion I > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > would like > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > to > > > > > > > > > > > > determine if the contents should be fetched from the > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > final > > > > > > > > > > > > > > > > > > > > > > > > > > > > > destination > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > or > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > not. > > > > > > > > > > > > > > > > > > > > > > > > For example, when I use HttpClient to fetch contents > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > from > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > URL: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > http://www.opensolaris.org/jive/login!withRedirect.jspa > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > The request gets automatically redirected to > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > https://auth.opensolaris.org/login.action?targetUrl=http://www.opensolaris.org/jive/message.jspa?messageID=219909 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > and HttpClient returns the html contents from > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > https://auth.opensolaris.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Based on the return code value from method.execute() > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > call I > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > have no > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > way > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > to > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > know that this happened. The return code is 200 > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > (HttpStatus.SC_OK). > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I have two questions as follows: > > > > > > > > > > > > 1> Is there any way to know that this redirect > happened > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > 2> Can I control redirects completely? Meaning, is > there > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > any > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > way to > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > tell > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > HttpClient to not to fetch content from the new URL > but > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > just > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > let the > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > calling > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > method know what this new URL is? > > > > > > > > > > > > > > > > > > > > > > > > Please note setting method.followRedirects() to true > or > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > false did > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > not > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > alter > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > the behavior. Irrespective of setting this flag to > false, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > the > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > HTML > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > contents > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > were fetched from https://auth.opensolaris.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Which version of HttpClient are you using? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks in advance! > > > > > > > > > > > > Rutuja > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > To unsubscribe, e-mail: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > httpclient-users-unsubscribe@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > For additional commands, e-mail: > > > > > > > > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > To unsubscribe, e-mail: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > httpclient-users-unsubscribe@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > For additional commands, e-mail: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > To unsubscribe, e-mail: > > > > > > > > httpclient-users-unsubscribe@... > > > > > > > > > For additional commands, e-mail: > > > > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > > > > > > > > > > > > > > > > > To unsubscribe, e-mail: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > httpclient-users-unsubscribe@... > > > > > > > > > > > > > > > > > > > > > > > > > > For additional commands, e-mail: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > > > > > > To unsubscribe, e-mail: > > > > > httpclient-users-unsubscribe@... > > > > > For additional commands, e-mail: > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > > > > > To unsubscribe, e-mail: > > > > > > > > > > > httpclient-users-unsubscribe@... > > > > > > > > > > For additional commands, e-mail: > > > > > > > > > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: > > > httpclient-users-unsubscribe@... > > > For additional commands, e-mail: > > > httpclient-users-help@... > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > httpclient-users-unsubscribe@... > > For additional commands, e-mail: > httpclient-users-help@... > > > > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@... For additional commands, e-mail: httpclient-users-help@... |
| Free embeddable forum powered by Nabble | Forum Help |