[
https://issues.apache.org/jira/browse/HTTPCLIENT-1267?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13509755#comment-13509755
]
Oleg Kalnichevski commented on HTTPCLIENT-1267:
-----------------------------------------------
@Karl
HTTP cookie management is such a bloody mess because too many people do not
care or did not care in the past. An HTTP cookie is logical concept that can
have different representations depending on a particular context. Various
cookie specs treat cookie differently depending on their version and
properties. Standard java object serialization based on ObjectInputStream and
ObjectOutputStream should work out of the box. Since your project implements a
custom cookie manager and a custom cookie store which decomposes cookies down
to individual bits and pieces and stores their state in a custom database, I do
not understand why it is my personal fault or that of HttpClient if does not do
it quite right. In order fix the problem the fetcher should either preserve the
original type of the cookie or use cookie representation compatible with the
cookie policy used by the fetcher.
Hope this helps
Oleg
> 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: [email protected]
For additional commands, e-mail: [email protected]