hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karl Wright (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCLIENT-1267) There seems to be no way to get HttpClient to include cookies from a custom store
Date Tue, 04 Dec 2012 09:50:58 GMT

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

Karl Wright commented on HTTPCLIENT-1267:
-----------------------------------------

Hi Francois,

I never had a copy of HttpClient 4.0-alpha1 here.
I built all of this using Maven as per the instructions, from a fresh checkout of (in this
case) httpcore.  Here is the class you say is not supposed to be present:

>>>>>>
C:\wip\httpcore\trunk\httpcore\src\main\java\org\apache\http\protocol>dir
 Volume in drive C is OS
 Volume Serial Number is 22F7-8854

 Directory of C:\wip\httpcore\trunk\httpcore\src\main\java\org\apache\http\proto
col

12/03/2012  05:24 PM    <DIR>          .
12/03/2012  05:24 PM    <DIR>          ..
12/03/2012  05:24 PM             3,091 BasicHttpContext.java
12/03/2012  05:24 PM             8,723 BasicHttpProcessor.java
12/03/2012  05:24 PM             3,533 ChainBuilder.java
12/03/2012  05:24 PM             2,852 DefaultedHttpContext.java
12/03/2012  05:24 PM             2,763 ExecutionContext.java
12/03/2012  05:24 PM             4,469 HTTP.java
12/03/2012  05:24 PM             2,842 HttpContext.java
12/03/2012  05:24 PM             3,933 HttpCoreContext.java
12/03/2012  05:24 PM             2,650 HttpDateGenerator.java
12/03/2012  05:24 PM             3,344 HttpExpectationVerifier.java
12/03/2012  05:24 PM             2,375 HttpProcessor.java
12/03/2012  05:24 PM             4,777 HttpProcessorBuilder.java
12/03/2012  05:24 PM            12,453 HttpRequestExecutor.java
12/03/2012  05:24 PM             2,456 HttpRequestHandler.java
12/03/2012  05:24 PM             1,863 HttpRequestHandlerMapper.java
12/03/2012  05:24 PM             3,657 HttpRequestHandlerRegistry.java
12/03/2012  05:24 PM             1,910 HttpRequestHandlerResolver.java
12/03/2012  05:24 PM             3,465 HttpRequestInterceptorList.java
12/03/2012  05:24 PM             3,490 HttpResponseInterceptorList.java
12/03/2012  05:24 PM            17,893 HttpService.java
12/03/2012  05:24 PM             5,726 ImmutableHttpProcessor.java
12/03/2012  05:24 PM             1,381 package.html
12/03/2012  05:24 PM             2,508 RequestConnControl.java
12/03/2012  05:24 PM             5,376 RequestContent.java
12/03/2012  05:24 PM             2,412 RequestDate.java
12/03/2012  05:24 PM             3,208 RequestExpectContinue.java
12/03/2012  05:24 PM             3,756 RequestTargetHost.java
12/03/2012  05:24 PM             2,729 RequestUserAgent.java
12/03/2012  05:24 PM             4,431 ResponseConnControl.java
12/03/2012  05:24 PM             5,647 ResponseContent.java
12/03/2012  05:24 PM             2,446 ResponseDate.java
12/03/2012  05:24 PM             2,411 ResponseServer.java
12/03/2012  05:24 PM             2,242 SyncBasicHttpContext.java
12/03/2012  05:24 PM             4,046 UriHttpRequestHandlerMapper.java
12/03/2012  05:24 PM             5,205 UriPatternMatcher.java
              35 File(s)        146,063 bytes
               2 Dir(s)  57,939,709,952 bytes free

C:\wip\httpcore\trunk\httpcore\src\main\java\org\apache\http\protocol>
<<<<<<

Karl

                
> There seems to be no way to get HttpClient to include cookies from a custom store
> ---------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1267
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1267
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpCookie
>    Affects Versions: 4.2.2
>            Reporter: Karl Wright
>
> In the port of ManifoldCF from commons-httpclient to httpcomponents, we discovered a
problem or maybe a design flaw with how cookies are handled.
> What we're trying to do is to follow a certain series of html pages, and record the cookies
after that is done, and use exactly those cookies for a subsequent series of pages.  So I
have code that looks something like this:
> {code}
> DefaultHttpClient httpClient = new DefaultHttpClient();
> ...
> CookieStore cs = new BasicCookieStore();
> cs.addCookie(...);  // for each saved cookie
> httpClient.setCookieStore(cs);
> HttpGet httpget = new HttpGet(...);
> HttpResponse response = httpClient.execute(httpget);
> Cookie[] cookiesToSave = httpClient.getCookieStore().getCookies();
> [save the cookies aside]
> {code}
> What happens when I do this against a page that sets a cookie, is I get a perfectly reasonable
cookie, and save it.  For the next page, the code to add the cookie to the custom store then
seems to work fine as well.  But when I watch what is transmitted for the request (via header
logging) I see no Cookie header being sent, and indeed the cookie seems to be lost.
> Similar logic was done with HttpState in commons-httpclient, and worked perfectly there
against the same website.
> I have not yet tried the HttpContext approach for implementing this - I may try that
while awaiting an answer to this ticket, but the above seems like it ought to work, according
to the documentation.

--
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