Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting "Set-Cookie" header
    text
    copied!<p>I'm trying to get 'Set Cookie' header using apache httpclietn-4.2.2 and having some problems.</p> <p>Header in Firebug:</p> <pre><code>Set-Cookie remixreg_sid=deleted; expires=Thu, 10-Nov-2011 04:32:30 GMT; path=/; domain=.vk.com remixapi_sid=deleted; expires=Thu, 10-Nov-2011 04:32:30 GMT; path=/; domain=.vk.com remixrec_sid=deleted; expires=Thu, 10-Nov-2011 04:32:30 GMT; path=/; domain=.vk.com remixsid=0000000000000000000000000000000000000000000000000000; expires=Mon, 04-Nov-2013 16:10:24 GMT; path=/; domain=.vk.com </code></pre> <p>How I'm trying to obtain it:</p> <pre><code> //location is a header with url I need to do GET request to Header location = response.getFirstHeader("Location"); HttpGet httpGet = new HttpGet(location.getValue()); httpClient.getParams().setParameter( //tried to use different policies ClientPNames.COOKIE_POLICY, CookiePolicy.RFC_2965); Header [] allHeaders=response.getAllHeaders(); </code></pre> <p>In allHeaders I have all headers except "Set Cookie". And I have warnings like this: </p> <pre><code>WARNING: Invalid cookie header: "Set-Cookie: remixlang=0; expires=Mon, 18-Nov-2013 03:21:47 GMT; path=/; domain=.vk.com". Unrecognized cookie header 'Set-Cookie: remixlang=0; expires=Mon, 18-Nov-2013 03:21:47 GMT; path=/; domain=.vk.com' Nov 09, 2012 4:31:41 AM org.apache.http.client.protocol.ResponseProcessCookies processCookies </code></pre> <p>So I think the problem is with 'expires' date.</p> <p>What I tried to do:</p> <p>1) <a href="https://stackoverflow.com/questions/9500714/invalid-cookie-header-unable-to-parse-expires-attribute-when-expires-attribute">Invalid cookie header : Unable to parse expires attribute when expires attribute is empty</a> Created custom CookieSpec and tried to use it:</p> <pre><code> httpClient.getCookieSpecs().register("vkCookie", new CookieSpecFactory() { public CookieSpec newInstance(HttpParams params){ return new VkCookieSpec(); } }); HttpClientParams.setCookiePolicy(httpClient.getParams(), "vkCookie"); </code></pre> <p>2) Tried to set Data Format in httpClient params :</p> <pre><code> httpClient.getParams().setParameter(CookieSpecPNames.DATE_PATTERNS, Arrays.asList("EEE, dd-MMM-yyyy HH:mm:ss z")); </code></pre> <p>But I'm still getting that warning. Would appreciate any help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload