hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pvbem...@xs4all.nl
Subject RE: httpcore parses expires in Set-Cookie wrong
Date Wed, 07 Nov 2012 18:43:17 GMT

Hi JM,

Look again: the ',' in

           "expires=Sun, 03-Nov-2013 10:54:41 GMT;"

is parsed as if it were a ';' .

That leads to
  expires=Sun
and
  03-Nov-2013 10:54:41 GMT=null

I can't believe I'm the first person to notice this...

Paul.


>
>Hi Paul,
>
>I don't see anything wrong with the output. What will have you expected?
>
>JM
>
>2012/11/6, pvbemmel@xs4all.nl <pvbemmel@xs4all.nl>:
>>
>> I'm using httpcore-4.2.1 , and code below shows the problem.
>> The code is similar to that on page 2 of the httpcore tutorial pdf.
>> I only added a Set-Cookie with an expires header element .
>> -------------------------------------------------------------------
>>
>> import org.apache.http.*;
>> import org.apache.http.message.*;
>>
>> public class Page2 {
>>
>>   public static void main(String[] args) {
>>     HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,
>>         HttpStatus.SC_OK, "OK");
>>     response.addHeader("Set-Cookie", "c1=a; path=/; domain=localhost");
>>     response.addHeader("Set-Cookie",
>>         "c2=b; path=\"/\", c3=c; domain=\"localhost\"");
>>     response.addHeader("Set-Cookie",
>>         "c2=b; expires=Sun, 03-Nov-2013 10:54:41 GMT;" +
>>         " path=\"/\", c3=c; domain=\"localhost\"");
>>     HeaderElementIterator it = new BasicHeaderElementIterator(
>>         response.headerIterator("Set-Cookie"));
>>     while (it.hasNext()) {
>>       HeaderElement elem = it.nextElement();
>>       System.out.println(elem.getName() + " = " + elem.getValue());
>>       NameValuePair[] params = elem.getParameters();
>>       for (int i = 0; i < params.length; i++) {
>>         System.out.println(" " + params[i]);
>>       }
>>     }
>>   }
>> }
>> -------------------------------------------------------------------
>> It produces output
>>
>> c1 = a
>>  path=/
>>  domain=localhost
>> c2 = b
>>  path=/
>> c3 = c
>>  domain=localhost
>> c2 = b
>>  expires=Sun
>> 03-Nov-2013 10:54:41 GMT = null
>>  path=/
>> c3 = c
>>  domain=localhost
>>
>> Clearly the date is parsed wrong.
>>
>> Is this a bug in httpcore, or am i doing something wrong?
>>
>> Regards,
>> Paul van Bemmelen
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>
>>



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message