World: r3wp
[!REBOL3 Schemes] Implementors guide
older newer | first last |
Graham 6-Jan-2010 [151x2] | 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 [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. |
older newer | first last |