r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!REBOL3 Schemes] Implementors guide

Graham
6-Jan-2010
[129x7]
For instance, in writing the AWS stuff, Maarten basically had to 
write his own http scheme ... because it wasn't easy to reuse the 
existing stuff.
I hope we can avoid that need for r3
if you look at the port object! after eg. opening rebol.com, there 
is a port/scheme/actor object, and then the actor object seems to 
be duplicated in port/actor ...
Is there actually any documentation on using the http apart from 
read ?
http://www.rebol.net/docs/HTTPScheme state diagram.png
Just a question about eg.

open http://www.rebol.com


Does 'open take the url, turn it into a port object, and then invokes 
the http scheme'' open on the port object?
scheme's 'open on the port object?
Steeve
6-Jan-2010
[136x2]
actually what is the question ? :-)
it's doing what you noted, so what ?
Graham
6-Jan-2010
[138]
just a stream of consciousness like Marcel Proust
Steeve
6-Jan-2010
[139]
:-)
Graham
6-Jan-2010
[140x2]
So, if you write your own schemes ... open must invoke the correct 
'open some how
looks like 'open is a native ... no source given
Steeve
6-Jan-2010
[142]
you're seeking the proto-open ?
Graham
6-Jan-2010
[143x2]
still streaming ..
AFAIK there's virtually no R3 documentation
Steeve
6-Jan-2010
[145]
i think you know this source system/intrinsic/make-port
Graham
6-Jan-2010
[146x7]
ahh.. that helps
there's no trace/net ?
I guess it's download wireshark time :(
HEAD / HTTP/1.0
Accept: */*
Accept-Charset: utf-8
Host: www.rebol.com
User-Agent: REBOL

HTTP/1.1 200 OK
Date: Wed, 06 Jan 2010 07:28:08 GMT

Server: Apache/1.3.37 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 
mod_bwlimited/1.4 PHP/4.4.7 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.28 
OpenSSL/0.9.7a
Last-Modified: Fri, 01 Jan 2010 21:19:01 GMT
ETag: "3f44376-2667-4b3e66c5"
Accept-Ranges: bytes
Content-Type: text/html
Via: 1.1 bc1
Content-Length: 9831
Connection: close
this was from ...


r: read open [ scheme: 'http host: "www.rebol.com" method: 'head 
port-id: 80 ]

but probe r
[x/ 9831 none ]
well I guess it tells me something is there .. as I don't get an 
error.  But 9831 is not very useful content.
r: read open [ scheme: 'http host: "www.rebol.com" method: 'head 
port-id: 80 headers: [ User-Agent: "Graham" Content-length: 0 ]]
works to override the headers
sqlab
6-Jan-2010
[153]
read p: open [scheme: 'http host: "www.rebol.com" method: 'head port-id: 
80 ]
probe p/state/info/headers
gives more information without wireshark
Graham
6-Jan-2010
[154]
That's useful ... I thought I molded the whole p and didn't see anything 
...
Steeve
6-Jan-2010
[155]
must initiate the path var to get a response from the server:
read [ scheme: 'http path: host: "www.rebol.com" method: 'head]

** Access error: protocol error: "Server error: HTTP/1.1 400 Bad 
Request"
Graham
6-Jan-2010
[156x2]
ok, to send stuff ... need to set a content: in the port spec.

[ content: "ehlo" scheme: 'http ..etc ]
You're sending 

HEAD www.rebol.com HTTP/1.0
Accept: */*
Accept-Charset: utf-8
Host: www.rebol.com
User-Agent: REBOL

which is invalid
Steeve
6-Jan-2010
[158]
ah ok
Graham
6-Jan-2010
[159x9]
Ok, we seem to have some basic information now on how to use the 
http protocol :)
This is a little inconsistent .. if I read www.rebol.com I get a 
binary returned

If I read http://www.compkarori.co.nz:8090 I get a string returned 
instead
in the latter case, there's no port/state/info ...
Infact port/state is none
looks like the port structure is being clobbered
anyway the state object is set to none in the latter case ...
I wonder why that should be ...
Gabriele: why is port/state set to none in the latter http read?
Trying to create some noob documentation on http http://rebol.wik.is/Rebol3/Schemes/Http
Gabriele
6-Jan-2010
[168x2]
Graham: i write top-down or bottom-up depending on the case. if i 
know *very well* were i am going, i usually work bottom-up. otherwise 
top-down generally gives much better results. the R3 http scheme 
was more bottom-up than top-down. however, i always tend to present 
the code top-down, for a number of reasons. first, most people are 
only interested in the interface (how to use the scheme) - they find 
that first. after that, people maybe just want to figure out why 
something is not working or how something works, so they just need 
to go a little bit deeper, and that means just reading a bit further. 
only someone who needs to figure out the whole thing needs to read 
the whole file.
Brian: you guys love to hurt yourselves, if you modified the .r directly.
Graham
6-Jan-2010
[170]
What is used to generate the .r from the .rlp ?
Gabriele
6-Jan-2010
[171x2]
Graham: re. the headers discussion above, spec/headers is the user 
supplied headers. the ones in there are the default one (the template). 
in order for the user to be able to override the default, it is make 
template spec/headers and not make spec/headers template.
Graham: IIRC the HTTP/1.0 was put in there as a quick fix because 
someone was complaining about bugs with HTTP/1.1... unless i'm confusing 
this with something else.
Graham
6-Jan-2010
[173x2]
I had a look on chat and there doesn't seem to be anything there 
....
well, 3 messages about http ... one of which was off topic
Gabriele
6-Jan-2010
[175]
Graham: this was writteng when binary! was still any-string!. then 
the code was changed quickly to make it work with the new unicode 
build (hence the crlfbin stuff and some of the hacks in the parse 
rules).
Graham
6-Jan-2010
[176]
So, it needs to be fixed ...
Gabriele
6-Jan-2010
[177x2]
port/state set to none: i don't remember, i'd need to investigate.
read returns binary if it can't convert the content to string (ie. 
content-type is not text/* and charset is not UTF-8.) this was a 
quick addition after the unicode changes, and needs much more work.