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

HTTP response header

 [1/5] from: tim-johnsons::web::com at: 23-Mar-2006 12:07


Hi: Is there a way to get the HTTP response header? Example: res: read http://www.rebol.com ;; returns a string with the content of that page. But what I'd really like to take a look at is the headers that precede the content. I know that this isn't rebol-specific, but :-) I'll bet one of you knows... thanks tim -- Tim Johnson <tim-johnsons-web.com> http://www.alaska-internet-solutions.com

 [2/5] from: compkarori:gma:il at: 24-Mar-2006 9:08


res: open http://www.rebol.com probe res/locals On 3/24/06, Tim Johnson <tim-johnsons-web.com> wrote:
> Hi: > Is there a way to get the HTTP response header?
<<quoted lines omitted: 12>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- Graham Chiu http://www.compkarori.com/emr/

 [3/5] from: tim-johnsons:web at: 23-Mar-2006 14:12


* Graham Chiu <compkarori-gmail.com> [060323 12:24]:
> res: open http://www.rebol.com > > probe res/locals >
Yes. That did it. thanks tim
> On 3/24/06, Tim Johnson <tim-johnsons-web.com> wrote: > >
<<quoted lines omitted: 28>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- Tim Johnson <tim-johnsons-web.com> http://www.alaska-internet-solutions.com

 [4/5] from: hallvard::ystad::gmail::com at: 24-Mar-2006 0:32


(Sorry for duplicates of this email, if any) Dixit Tim Johnson (22.07 23.03.2006): Hi: Is there a way to get the HTTP response header? Here's the output from make money! .2 : You could have a look at this script from the rebol.org library: http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=http-get.r&sid=k8wk ...or use the following script that I use, but it's based on http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=url-handler.r: REBOL [ Title: "URL fetcher returning both content and headers of a URL" File: %fetch-url.r Author: [ "HY" ] Date: 1-Jan-2005 History: [ 1-Jan-2005 {Extracted the function into it's own file.} ] ] do %url-handler.r fetch-url: func [ full-url [string! url!] /headers header-block /local site ] [ to-fetch: url-handler to-string full-url if not headers [header-block: [connection: close] ] ;to-insert: rejoin [ "GET " to-fetch/as-string/from-path-only " HTTP/1.1^/Host: " to-fetch/host "^/" ] to-insert: rejoin [ "GET " to-fetch/as-string/from-path-only " HTTP/1.0^/Host: " to-fetch/host "^/" ] foreach [key value] header-block [ append to-insert rejoin [ key ": " value "^/" ] ] append to-insert "^/" port: open/lines [ scheme: 'tcp host: to-fetch/host port-id: 80 ] print "[Vi sender:]" print form to-insert insert port to-insert header: make block! 10 while [ not empty? reply: first port ] [ parse reply [ [copy name [thru #":"] (name: load name) | copy name [to end] (print form name)] [copy value to newline | copy value to end] (if value [append header reduce [name value]]) ] ] either [ not empty? content: first port ] [content: copy port] [print EMPTY! ] close port reduce [header content] ] a: fetch-url http://www.rebol.com/ print mold first a print "^/^/===^/^/" ;print second a halt ; END OF SCRIPT HY

 [5/5] from: tim-johnsons:web at: 23-Mar-2006 16:23


* Hallvard Ystad <hallvard.ystad-gmail.com> [060323 14:40]: That could be handy. Thanks Here's what I did: get-html-response: def[ "Get HTML response headers." request[url!] /with attr[word!] "get single header attribute"][ res: open request either res[ either with [probe res/locals/headers/:attr] [probe res/locals] close res ][none] ]
> (Sorry for duplicates of this email, if any) > Dixit Tim Johnson (22.07 23.03.2006):
<<quoted lines omitted: 60>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- Tim Johnson <tim-johnsons-web.com> http://www.alaska-internet-solutions.com

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