How to pass cookie URL using Rebol 3?

Using R3, I need to get a localized version of the page from a website using cookies to process this. In REBOL 2.x, I could do this:

page: http://www.rci.com/resort-directory/resortDetails?resortCode=0450 read/custom page [header [Cookie: "USER_LOCALE=fr_FR"]] 

Based on sketchy docs for R3, I should do something like:

 result: write page [GET [Cookie: "USER_LOCALE"] {fr_FR}] 

Does anyone have any ideas? The R2 method worked well, but since R2 does not handle UTF-8, which is necessary for many foreign languages, it doesn’t work for me.

** Update **

Solution (recounted) in R2 for my example:

  • Collect the necessary parameters in a cookie:

     cookie-str: "USER_LOCALE=fr_FR; USER_COUNTRY=US" 
  • Then paste the cookie in the header

     page-code: read/custom page reduce compose/deep ['header [Cookie: (cookie-str)]] 

Solution for my example in R3:

 page-code: to-string write page reduce compose/deep ['GET [Cookie: (cookie-str)]] 
+5
source share
1 answer

Your attempt is almost yours. You use WRITE with a small “HTTP dialect” in the argument block when you need to configure something about the HTTP request being sent. The first element of this dialect is the HTTP method, the second element (if present) is the block of HTTP headers to send.

If I understand your example correctly, you want to send a cookie with "USER_LOCALE = fr_FR" as a payload. So you would do:

 write page [GET [Cookie: {USER_LOCALE=fr_FR}]] 

Let me check this out on httpbin :

 >> print to-string write http://httpbin.org/headers [GET [Cookie: "USER_LOCALE=fr_FR"]] { "headers": { "Accept": "*/*", "Accept-Charset": "utf-8", "Cookie": "USER_LOCALE=fr_FR", "Host": "httpbin.org", "User-Agent": "REBOL" } } 
+6
source

All Articles