The read
and write
commands in Rebol, when passed a URL! parameter, can get you either a binary response or an error. So in the "one-off" style of doing a GET or a POST there is nowhere to get the response headers from.
result: read http://www.rebol.com
In this post about how to do it in Rebol2, it suggests you have to open a port! and get it from the port's local/headers field:
This works in Rebol2, for instance
hp: open http://www.rebol.com
result: read hp
probe hp/locals/headers/Content-Encoding
But in Rebol3, when I open a port and try this the locals field of the port is empty. How to achieve the same behavior in Rebol3?
Is this what you're looking for?
>> hp: open http://www.rebol.com/
>> to string! read hp
== {<!doctype html>
<html><head>
<meta name="generator" content="REBOL WIP Wiki"/>
<meta name="date" content="16-Feb-2014/15:58:59-8:00"/>
<meta name="rebol-version" content="2.100.97.4.2"/>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta name="Description" content="REBOL: a lightweight computer language with ad
vanced semantics. ...
>> query hp
== make object! [
name: %/
size: 7118
date: none
type: 'file
response-line: "HTTP/1.1 200 OK"
response-parsed: 'ok
headers: make object! [
Content-Length: 7118
Transfer-Encoding: none
Last-Modified: "Sun, 16 Feb 2014 23:58:59 GMT"
Date: "Sat, 05 Apr 2014 08:19:34 GMT"
Server: "Apache"
Accept-Ranges: "bytes"
Connection: "close"
Content-Type: "text/html"
]
]