Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Custom HTTP header

 [1/5] from: francis:franfran at: 24-Oct-2010 20:55


Hi, I am a new comer in Rebol world, and would like to ask a question about block. If I want to download a page with a custom HTTP header, I could do:
>>
read/custom http://192.168.1.100:8080 [ header [ Cookie: "a=1234" Referer: "http://www.xyz.com" ] ] However, if I want to assign the header as a word first, the following won't work.
>>
custom-header: [ Cookie: "a=1234" Referer: "http://www.xyz.com" ] read/custom http://192.168.1.100:8080 [ header custom-header ] It is because the custom-header got evaluated rather than passing as data, and I could confirm this by:
>>
print cookie a=1234 May I know how can I solve this problem by using the correct syntax? Thank you very much! franfran

 [2/5] from: dhsunanda:gm:ail at: 24-Oct-2010 14:44


Francis Mak:
> May I know how can I solve this problem by using the correct syntax?
Try something like this: custom-header: [ Cookie: "a=1234" Referer: "http://www.xyz.com" ] read/custom http://192.168.1.100:8080 append/only [header] custom-header Sunanda.

 [3/5] from: francis:franfran at: 24-Oct-2010 22:06


Hi Sunanda, Thx for the direction of append command, it works. franfran

 [4/5] from: gregg:pointillistic at: 24-Oct-2010 11:04


S> read/custom http://192.168.1.100:8080 append/only [header] custom-header If you're code is in a function, you'll want to include a COPY in there, use JOIN, or something else. read/custom http://192.168.1.100:8080 append/only copy [header] custom-header read/custom http://192.168.1.100:8080 join [header] [custom-header] read/custom http://192.168.1.100:8080 rejoin [[header] custom-header] ; Thanks to Ladislav for reminding me about REJOIN with an initial block arg. hdr: [header []] hdr/header: custom-header read/custom http://192.168.1.100:8080 hdr -- Gregg

 [5/5] from: santilli:gabriele:gm:ail at: 24-Oct-2010 19:13


On Sun, Oct 24, 2010 at 7:04 PM, Gregg Irwin <gregg-pointillistic.com> wrote:
> =C2=A0 =C2=A0read/custom http://192.168.1.100:8080 append/only copy [header] custom-header > =C2=A0 =C2=A0read/custom http://192.168.1.100:8080 join [header] [custom-header]
<<quoted lines omitted: 4>>
> =C2=A0 =C2=A0hdr/header: custom-header > =C2=A0 =C2=A0read/custom http://192.168.1.100:8080 hdr
Well, while we're at it... reduce ['header custom-header] compose/deep [header [(custom-header)]] ; copies custom-header compose/only [header (custom-header)]

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted