You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Toshimasa NASU (JIRA)" <ji...@apache.org> on 2013/06/07 12:14:20 UTC
[jira] [Comment Edited] (HTTPCLIENT-1367) decoded PATH of cookie
value in CookieOrigin
[ https://issues.apache.org/jira/browse/HTTPCLIENT-1367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13677934#comment-13677934 ]
Toshimasa NASU edited comment on HTTPCLIENT-1367 at 6/7/13 10:12 AM:
---------------------------------------------------------------------
Oleg
thank you for comment.
I want an redirect URL when it was redirected.
I refer to 'http.protocol.redirect-locations' first.
next 'http.cookie-origin'.
When I restore an redirect URL from Cookie, '/' becomes '%2f'.
Because I cannot restore an redirect URL, I want RAW PATH.
//
Object redirect = context.getAttribute(DefaultRedirectStrategy.REDIRECT_LOCATIONS);
if (redirect instanceof RedirectLocations) {
RedirectLocations locations = (RedirectLocations)redirect;
List list = locations.getAll();
return list.get(list.size() - 1).toString();
}
Object cookie = context.getAttribute(ClientContext.COOKIE_ORIGIN);
if (cookie instanceof CookieOrigin) {
CookieOrigin origin = (CookieOrigin)cookie;
StringBuilder buf = new StringBuilder();
if (origin.isSecure()) {
buf.append("https://");
} else {
buf.append("http://");
}
buf.append(origin.getHost());
if (origin.getPort() > 0 && origin.getPort() != 80 && origin.getPort() != 443) {
buf.append(":" + String.valueOf(origin.getPort()));
}
buf.append(origin.getPath());
return buf.toString();
}
return null;
//
was (Author: nasu_t):
Oleg
thank you for comment.
I want an redirect URL when it was redirected.
I refer to 'http.protocol.redirect-locations' first.
next 'http.cookie-origin'.
When I restore an redirect URL from Cookie, '/' becomes '%2f'.
Because I cannot restore an redirect URL, I want RAW PATH.
//
Object redirect = context.getAttribute(DefaultRedirectStrategy.REDIRECT_LOCATIONS);
if (redirect instanceof RedirectLocations) {
RedirectLocations locations = (RedirectLocations)redirect;
List list = locations.getAll();
return list.get(list.size() - 1).toString();
}
Object cookie = context.getAttribute(ClientContext.COOKIE_ORIGIN);
if (cookie instanceof CookieOrigin) {
CookieOrigin origin = (CookieOrigin)cookie;
StringBuilder buf = new StringBuilder();
if (origin.isSecure()) {
buf.append("https://");
} else {
buf.append("http://");
}
buf.append(origin.getHost());
if (origin.getPort() > 0 && origin.getPort() != 80 && origin.getPort() != 443) {
buf.append(":" + String.valueOf(origin.getPort()));
}
buf.append(origin.getPath());
return buf.toString();
}
return null;
//
> decoded PATH of cookie value in CookieOrigin
> --------------------------------------------
>
> Key: HTTPCLIENT-1367
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1367
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Reporter: Toshimasa NASU
>
> I used CookieOrigin. but path was decoded.
> org.apache.http.client.protocol.RequestAddCookies#process(HttpRequest, HttpContext)
> //
> URI requestURI;
> if (request instanceof HttpUriRequest) {
> requestURI = ((HttpUriRequest) request).getURI();
> } else {
> try {
> requestURI = new URI(request.getRequestLine().getUri());
> } catch (URISyntaxException ex) {
> throw new ProtocolException("Invalid request URI: " +
> request.getRequestLine().getUri(), ex);
> }
> }
> //
> CookieOrigin cookieOrigin = new CookieOrigin(
> hostName,
> port,
> requestURI.getPath(), // THIS IS PROBLEM.
> //requestURI.getRawPath(), // I HOPE THIS. because "requestURI.getPath()" was decoded PATH.
> conn.isSecure());
> //
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org