www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Curl - Set cookie value

reply "andre" <andre s-e-a-p.de> writes:
Hi,

from a GET request I receive an value "set-cookie" in the reponse 
header. The value from "set-cookie" I have to provide as cookie 
value for the next post request. CURL provides a command line 
command
   --cookie "USER_TOKEN=Yes"

In the std.net.curl HTTP API, there is no possibility to set a 
cookie value.

Could you check?

Kind regards
André
Oct 05 2014
parent "andre" <andre s-e-a-p.de> writes:
I found out the real issue. Using addRequestHeader also works for 
cookies, but there is an issue with HTTP attribute 
responseHeaders.
As this attribute is an associative array (string[string]) it 
contains only 1 value for 1 key.
In case there are several HTTP keys with the same name, it only 
contains the last value.
Example:

set-cookie = A; path=/; HttpOnly
set-cookie = B; path=/; HttpOnly
content-type = text/plain

reponseHeaders["set-cookie"] contains only the seccond value.
To work around this issue you have to react on "onReceiveHeader"
and catch the values there.

Kind regards
André

On Monday, 6 October 2014 at 06:43:58 UTC, andre wrote:
 Hi,

 from a GET request I receive an value "set-cookie" in the 
 reponse header. The value from "set-cookie" I have to provide 
 as cookie value for the next post request. CURL provides a 
 command line command
   --cookie "USER_TOKEN=Yes"

 In the std.net.curl HTTP API, there is no possibility to set a 
 cookie value.

 Could you check?

 Kind regards
 André
Oct 06 2014