* Hallvard Ystad <[EMAIL PROTECTED]> [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 =20
either res[
either with
[probe res/locals/headers/:attr]
[probe res/locals]
close res
][none]
]
> (Sorry for duplicates of this email, if any)
>=20
> Dixit Tim Johnson (22.07 23.03.2006):
>=20
> Hi:
> Is there a way to get the HTTP response header?
>=20
>=20
>=20
> Here's the output from make money! .2 :
>=20
> 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=3Dhttp-=
get.r&sid=3Dk8wk
>=20
> ...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=3Durl-h=
andler.r:
>=20
>=20
> 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.}
> ]
> ]
>=20
> do %url-handler.r
>=20
> fetch-url: func [ full-url [string! url!] /headers header-block /local =
site
> ] [
>=20
> to-fetch: url-handler to-string full-url
>=20
> if not headers [header-block: [connection: close] ]
>=20
> ;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 "^/" ]
>=20
> foreach [key value] header-block [
> append to-insert rejoin [ key ": " value "^/" ]
> ]
>=20
> append to-insert "^/"
>=20
> port: open/lines [
> scheme: 'tcp
> host: to-fetch/host
> port-id: 80
> ]
>=20
> print "[Vi sender:]"
> print form to-insert
>=20
> insert port to-insert
>=20
> header: make block! 10
> while [ not empty? reply: first port ] [
> parse reply [
> [copy name [thru #":"] (name: load name) | copy name [to end] (pr=
int
> form name)]
> [copy value to newline | copy value to end] (if value [append hea=
der
> reduce [name value]])
> ]
> ]
>=20
> either [ not empty? content: first port ] [content: copy port] [print
> "EMPTY!"]
>=20
> close port
>=20
> reduce [header content]
> ]
>=20
>=20
> a: fetch-url http://www.rebol.com/
>=20
> print mold first a
>=20
> print "^/^/=3D=3D=3D^/^/"
>=20
> ;print second a
> halt
> ; END OF SCRIPT
>=20
>=20
> HY
> Pr=E6tera censeo Carthaginem esse delendam
>=20
> --=20
> To unsubscribe from the list, just send an email to=20
> lists at rebol.com with unsubscribe as the subject.
--=20
Tim Johnson <[EMAIL PROTECTED]>
http://www.alaska-internet-solutions.com
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.