You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Johannes Koch <jo...@fit.fraunhofer.de> on 2008/01/10 15:06:01 UTC
URI created without query
In method getLocationURI(HttpResponse, HttpContext) of
org.apache.http.impl.client.DefaultRedirectHandler:
if (uri.getQuery() != null || uri.getFragment() != null) {
try {
redirectURI = new URI(
uri.getScheme(),
null,
uri.getHost(),
uri.getPort(),
uri.getPath(),
null,
null);
} catch (URISyntaxException ex) {
throw new ProtocolException(ex.getMessage(), ex);
}
}
Why is the new URI created without the query component?
A redirect from http://example.org/foo?bar to A redirect from
http://example.org/foo?blah would so result in a CircularRedirectException.
--
Johannes Koch
BIKA Web Compliance Center - Fraunhofer FIT
Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
Phone: +49-2241-142628 Fax: +49-2241-142065
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: URI created without query
Posted by Ortwin Glück <od...@odi.ch>.
Yes, that indeed looks wrong to me.
Johannes Koch wrote:
> In method getLocationURI(HttpResponse, HttpContext) of
> org.apache.http.impl.client.DefaultRedirectHandler:
>
> if (uri.getQuery() != null || uri.getFragment() != null) {
> try {
> redirectURI = new URI(
> uri.getScheme(),
> null,
> uri.getHost(),
> uri.getPort(),
> uri.getPath(),
> null,
> null);
> } catch (URISyntaxException ex) {
> throw new ProtocolException(ex.getMessage(), ex);
> }
> }
>
> Why is the new URI created without the query component?
>
> A redirect from http://example.org/foo?bar to A redirect from
> http://example.org/foo?blah would so result in a CircularRedirectException.
>
--
[web] http://www.odi.ch/
[blog] http://www.odi.ch/weblog/
[pgp] key 0x81CF3416
finger print F2B1 B21F F056 D53E 5D79 A5AF 02BE 70F5 81CF 3416
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: URI created without query
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2008-01-10 at 17:17 +0100, Johannes Koch wrote:
> Oleg Kalnichevski schrieb:
> > And what about the test case?
>
> Does it make sense to remove the query
>
> "?invk=" + (++this.invocations)
>
> from the URIs in
> TestRedirects.CircularRedirectService.handle(
> final HttpRequest request,
> final HttpResponse response,
> final HttpContext context)
>
> ?
It appears so. I checked both patches in. Many thanks, Johannes
Oleg
> plain text document attachment (Patch_TestRedirects_20080110.txt)
> Index: D:/koch/opt/eclipse/workspace_p/httpclient_module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java
> ===================================================================
> --- D:/koch/opt/eclipse/workspace_p/httpclient_module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java (revision 610764)
> +++ D:/koch/opt/eclipse/workspace_p/httpclient_module-client/src/test/java/org/apache/http/client/protocol/TestRedirects.java (working copy)
> @@ -145,10 +145,10 @@
> String uri = request.getRequestLine().getUri();
> if (uri.startsWith("/circular-oldlocation")) {
> response.setStatusLine(ver, HttpStatus.SC_MOVED_TEMPORARILY);
> - response.addHeader(new BasicHeader("Location", "/circular-location2?invk=" + (++this.invocations)));
> + response.addHeader(new BasicHeader("Location", "/circular-location2"));
> } else if (uri.startsWith("/circular-location2")) {
> response.setStatusLine(ver, HttpStatus.SC_MOVED_TEMPORARILY);
> - response.addHeader(new BasicHeader("Location", "/circular-oldlocation?invk=" + (++this.invocations)));
> + response.addHeader(new BasicHeader("Location", "/circular-oldlocation"));
> } else {
> response.setStatusLine(ver, HttpStatus.SC_NOT_FOUND);
> }
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: URI created without query
Posted by Johannes Koch <jo...@fit.fraunhofer.de>.
Oleg Kalnichevski schrieb:
> And what about the test case?
Does it make sense to remove the query
"?invk=" + (++this.invocations)
from the URIs in
TestRedirects.CircularRedirectService.handle(
final HttpRequest request,
final HttpResponse response,
final HttpContext context)
?
--
Johannes Koch
BIKA Web Compliance Center - Fraunhofer FIT
Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
Phone: +49-2241-142628 Fax: +49-2241-142065
Re: URI created without query
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2008-01-10 at 16:48 +0100, Johannes Koch wrote:
> Johannes Koch schrieb:
> > Ortwin Glück schrieb:
> >>> Yep, what about the fragment component?
> >>
> >> No, fragments are not handled by HTTP Servers. They are only handeled
> >> by clients (browser).
> >
> > Then to make it consistent, I will also change
> >
> > URI absoluteRequestURI = new URI(
> > target.getSchemeName(),
> > null,
> > target.getHostName(),
> > target.getPort(),
> > requestURI.getPath(),
> > requestURI.getQuery(),
> > requestURI.getFragment());
> >
> > to
> > ...
> > requestURI.getQuery(),
> > null);
> >
>
> See attached patch.
>
And what about the test case?
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: URI created without query
Posted by Ortwin Glück <od...@odi.ch>.
Yes, definitely the fragment has no business in a RedirectHandler. It
only makes sense maybe to provide it at the final destination, so the
caller can check where he has ended up.
Johannes Koch wrote:
> Johannes Koch schrieb:
>> Ortwin Glück schrieb:
>>>> Yep, what about the fragment component?
>>>
>>> No, fragments are not handled by HTTP Servers. They are only handeled
>>> by clients (browser).
>>
>> Then to make it consistent, I will also change
>>
>> URI absoluteRequestURI = new URI(
>> target.getSchemeName(),
>> null,
>> target.getHostName(),
>> target.getPort(),
>> requestURI.getPath(),
>> requestURI.getQuery(),
>> requestURI.getFragment());
>>
>> to
>> ...
>> requestURI.getQuery(),
>> null);
>>
>
> See attached patch.
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
--
[web] http://www.odi.ch/
[blog] http://www.odi.ch/weblog/
[pgp] key 0x81CF3416
finger print F2B1 B21F F056 D53E 5D79 A5AF 02BE 70F5 81CF 3416
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: URI created without query
Posted by Johannes Koch <jo...@fit.fraunhofer.de>.
Johannes Koch schrieb:
> Ortwin Gl�ck schrieb:
>>> Yep, what about the fragment component?
>>
>> No, fragments are not handled by HTTP Servers. They are only handeled
>> by clients (browser).
>
> Then to make it consistent, I will also change
>
> URI absoluteRequestURI = new URI(
> target.getSchemeName(),
> null,
> target.getHostName(),
> target.getPort(),
> requestURI.getPath(),
> requestURI.getQuery(),
> requestURI.getFragment());
>
> to
> ...
> requestURI.getQuery(),
> null);
>
See attached patch.
--
Johannes Koch
BIKA Web Compliance Center - Fraunhofer FIT
Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
Phone: +49-2241-142628 Fax: +49-2241-142065
Re: URI created without query
Posted by Johannes Koch <jo...@fit.fraunhofer.de>.
Ortwin Glück schrieb:
>> Yep, what about the fragment component?
>
> No, fragments are not handled by HTTP Servers. They are only handeled by
> clients (browser).
Then to make it consistent, I will also change
URI absoluteRequestURI = new URI(
target.getSchemeName(),
null,
target.getHostName(),
target.getPort(),
requestURI.getPath(),
requestURI.getQuery(),
requestURI.getFragment());
to
...
requestURI.getQuery(),
null);
--
Johannes Koch
BIKA Web Compliance Center - Fraunhofer FIT
Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
Phone: +49-2241-142628 Fax: +49-2241-142065
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: URI created without query
Posted by Ortwin Glück <od...@odi.ch>.
Johannes Koch wrote:
> Oleg Kalnichevski schrieb:
>> On Thu, 2008-01-10 at 15:06 +0100, Johannes Koch wrote:
>>> Why is the new URI created without the query component?
>>>
>>
>> It is a bug. Could you please put together a patch to fix this?
>
> Yep, what about the fragment component?
No, fragments are not handled by HTTP Servers. They are only handeled by
clients (browser).
--
[web] http://www.odi.ch/
[blog] http://www.odi.ch/weblog/
[pgp] key 0x81CF3416
finger print F2B1 B21F F056 D53E 5D79 A5AF 02BE 70F5 81CF 3416
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: URI created without query
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2008-01-10 at 15:57 +0100, Johannes Koch wrote:
> Oleg Kalnichevski schrieb:
> > On Thu, 2008-01-10 at 15:06 +0100, Johannes Koch wrote:
> >> Why is the new URI created without the query component?
> >>
> >
> > It is a bug. Could you please put together a patch to fix this?
>
> Yep, what about the fragment component?
>
> BTW,
> org.apache.http.client.protocol.TestRedirects.testCircularRedirect()
> expects the CircularRedirectException.
>
Johannes,
If the behavior of a particular test case does not make sense feel free
to adjust it.
Cheers
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: URI created without query
Posted by Johannes Koch <jo...@fit.fraunhofer.de>.
Oleg Kalnichevski schrieb:
> On Thu, 2008-01-10 at 15:06 +0100, Johannes Koch wrote:
>> Why is the new URI created without the query component?
>>
>
> It is a bug. Could you please put together a patch to fix this?
Yep, what about the fragment component?
BTW,
org.apache.http.client.protocol.TestRedirects.testCircularRedirect()
expects the CircularRedirectException.
--
Johannes Koch
BIKA Web Compliance Center - Fraunhofer FIT
Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
Phone: +49-2241-142628 Fax: +49-2241-142065
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: URI created without query
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2008-01-10 at 15:06 +0100, Johannes Koch wrote:
> In method getLocationURI(HttpResponse, HttpContext) of
> org.apache.http.impl.client.DefaultRedirectHandler:
>
> if (uri.getQuery() != null || uri.getFragment() != null) {
> try {
> redirectURI = new URI(
> uri.getScheme(),
> null,
> uri.getHost(),
> uri.getPort(),
> uri.getPath(),
> null,
> null);
> } catch (URISyntaxException ex) {
> throw new ProtocolException(ex.getMessage(), ex);
> }
> }
>
> Why is the new URI created without the query component?
>
It is a bug. Could you please put together a patch to fix this?
Oleg
> A redirect from http://example.org/foo?bar to A redirect from
> http://example.org/foo?blah would so result in a CircularRedirectException.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org
Re: URI created without query
Posted by Johannes Koch <jo...@fit.fraunhofer.de>.
Johannes Koch schrieb:
> A redirect from http://example.org/foo?bar to A redirect from
> http://example.org/foo?blah would so result in a CircularRedirectException.
Oops, should read:
A redirect from http://example.org/foo?bar to
http://example.org/foo?blah would so result in a CircularRedirectException.
--
Johannes Koch
BIKA Web Compliance Center - Fraunhofer FIT
Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
Phone: +49-2241-142628 Fax: +49-2241-142065
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org