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
[167]
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
[177x4]
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.
also, there was documentation in the wiki...
http://www.rebol.net/wiki/Scheme:_HTTP
Graham
6-Jan-2010
[181]
ahh... couldn't find that ...
Gabriele
6-Jan-2010
[182]
the .r file is generated by Wetan, it was provided in r3-alpha together 
with the .r and the .rlp, but is probably not on r3 chat.
Graham
6-Jan-2010
[183]
read r: open [ scheme: 'http host: "www.compkarori.co.nz" port-id: 
8090 ]
probe r/state 
none
Gabriele
6-Jan-2010
[184x2]
of note, you are not supposed to look inside port in principle. so, 
apart from "playing" with it, you should not really expect to be 
able to do something like that.
maybe what you want is the result of QUERY?
Graham
6-Jan-2010
[186x3]
haven't got to query? yet :)
info: query port 
none
How do you access make-http-request ?  What's the path to this function?
Gabriele
6-Jan-2010
[189x2]
i don't remember when that can happen (i think you should always 
get something if you did a successfull request).
make-http-request is called from the read or write operations. eg. 
write [head %index.html] will make a HEAD request etc.
Graham
6-Jan-2010
[191x2]
but how can I access it ?
I followed the example to the letter with my url . ... and I get 
none
Gabriele
6-Jan-2010
[193]
in what sense? how do you need to access it?
Graham
6-Jan-2010
[194]
Say I want to create http header ... to sign it
Gabriele
6-Jan-2010
[195x2]
ah, aws. there is no direct way currently. that's what you get when 
people abuse http. :-) it should not be difficult though to allow 
the user to specify a callback for aws-like signatures etc.
or, just define a aws:// scheme inside the same module as http:// 
so that 99% of the code is reused.
Graham
6-Jan-2010
[197]
so these functions are inaccessible outside of the scheme?
Gabriele
6-Jan-2010
[198]
well, back when this was written, there were no modules yet, so everything 
was actually global.
Graham
6-Jan-2010
[199]
And now it's a module and hidden !
Gabriele
6-Jan-2010
[200]
now, in principle, prot-http.r should be a module. so, they can be 
imported from there, in principle. where the module is i don't know 
(this was much after i worked on this), i guess inside system/something 
, like system/modules or something like that.
Graham
6-Jan-2010
[201x3]
oh ...there it is
system/modules/http/make-http-request
Anyway, there does appear to be some type of bug that is setting 
state to none in the port .. and so query returns none
Gabriele
6-Jan-2010
[204]
it is possible... it's not like this was greatly tested (back then, 
not many people volunteered to test...), and it was written for a 
very different R3...
Graham
6-Jan-2010
[205]
there doesn't seem to be any inbuilt trace as in r2 ....
Gabriele
6-Jan-2010
[206x2]
except from using print directly in the scheme code, there was no 
way to do that at the time.
R3's trace function is very good now though, maybe that is enough.
Graham
6-Jan-2010
[208]
trace true   ????
Gabriele
6-Jan-2010
[209]
it has more options than that :)
Graham
6-Jan-2010
[210x3]
oh .. have to restart rebol and set secure
secure allow
yeah ... very detailed
Gabriele
6-Jan-2010
[213x2]
one of the things i wanted to do, but never got to, was to parse 
the output of R3's trace, and then show you a step-by-step code execution 
like in debuggers.
if trace were to add timestamps as well, then it could be used for 
both debugging and profiling, even on programs running on other people 
systems (they just save the trace, and you just load them).
Graham
6-Jan-2010
[215]
sounds good :)
Gabriele
6-Jan-2010
[216]
now someone with free time should start writing it :P