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] [Comment Edited] (HTTPCLIENT-1367) decoded PATH of cookie value in CookieOrigin
Date Fri, 07 Jun 2013 10:14:20 GMT

    [ 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


Mime
View raw message