hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Toshimasa NASU (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1367) decoded PATH of cookie value in CookieOrigin
Date Mon, 10 Jun 2013 01:46:20 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-1367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13679258#comment-13679258
] 

Toshimasa NASU commented on HTTPCLIENT-1367:
--------------------------------------------

Oleg

OK.THANKS.
I get it from HTTP_REQUEST.
Where should I take protocol and host and port from?
Is it COOKIE_ORIGIN or HTTP_TARGET_HOST?

//
        Object redirect = context.getAttribute(DefaultRedirectStrategy.REDIRECT_LOCATIONS);
        if (redirect instanceof RedirectLocations) {
            RedirectLocations locations = (RedirectLocations)redirect;
            @SuppressWarnings("rawtypes")
            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()));
            }
            Object http = context.getAttribute(ExecutionContext.HTTP_REQUEST);
            if (http instanceof HttpRequest) {
                HttpRequest request = (HttpRequest)http;
                buf.append(request.getRequestLine().getUri());
                return buf.toString();
            }
        }
        return null;
//

//
        Object redirect = context.getAttribute(DefaultRedirectStrategy.REDIRECT_LOCATIONS);
        if (redirect instanceof RedirectLocations) {
            RedirectLocations locations = (RedirectLocations)redirect;
            @SuppressWarnings("rawtypes")
            List list = locations.getAll();
            return list.get(list.size() - 1).toString();
        }
        Object target = context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
        if (target instanceof HttpHost) {
            HttpHost host = (HttpHost)target;
            StringBuilder buf = new StringBuilder();
            buf.append(host.toURI());
            Object http = context.getAttribute(ExecutionContext.HTTP_REQUEST);
            if (http instanceof HttpRequest) {
                HttpRequest request = (HttpRequest)http;
                buf.append(request.getRequestLine().getUri());
                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


Mime
View raw message