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

World: r3wp

[!REBOL3 Schemes] Implementors guide

ChristianE
20-Feb-2010
[2034]
Yes, that's what I'm after, Gabriele. Opening a network port and 
then waiting for network, time, or gui events.
Gabriele
20-Feb-2010
[2035]
Christian: does the example on the wiki work? If not, then something 
has been changed since then, and I can't help much without studying 
everything back again. If so, then maybe we can figure out why your 
version does not work.
Graham
20-Feb-2010
[2036]
studying your own code ?  :)
Gabriele
20-Feb-2010
[2037x2]
ie. this one:

   port: make port! http://www.rebol.com/
   port/awake: func [event] [
       switch event/type [
           connect [read event/port]
           done [print copy event/port return true]
       ]
       false
   ]
   open port
   wait port
Graham: mostly, the changes in R3, and trying to figure out how it 
works now. It's not like there are docs with enough details...
ChristianE
20-Feb-2010
[2039]
Gabriele, that's the main point of confusion to me, that even that 
example fails. I.e.. hangs when DONE, in the same way as my attempts 
on this.
Gabriele
20-Feb-2010
[2040]
Ok, so it's not your fault. R3 has changed and the HTTP scheme does 
not work correctly anymore.
ChristianE
20-Feb-2010
[2041]
Good to know. I like the line "It's not like there are docs with 
enough details..."
Graham
20-Feb-2010
[2042x2]
I think I read somewhere Brian saying that http had to be modified 
as chunked encoding didn't work or something like that
But the source was modified and not the rlp
Pekr
20-Feb-2010
[2044]
IIRC http was degraded to 1.0 from 1.1 due a problem Graham describes 
...
Graham
20-Feb-2010
[2045x3]
Isn't there a source code revision history somewhere??
so we can see exactly what was changed?
Looks like we need a set of unit tests for the protocols ...
BrianH
20-Feb-2010
[2048]
All changes to the source are in DevBase.
Graham
20-Feb-2010
[2049x2]
devbase??
last contribution to devbase was 1 mar 2009 by yourself
ChristianE
21-Feb-2010
[2051x6]
More likely than changes to the http-prot source being the reason 
for the async behaviour not working as expected are changes to the 
core itself.
That's my guess.
I tried against Gabriele's original pto-http sources as from the 
*.rlp, not the *.r as touched by Carl. Only thing I changed was two 
replacements of THIRD with BODY-OF.
No luck even with older R3 versions; version 2.100.33.3.1 dating 
back to 2009-01-28 being the oldest I have around.
*pto-http = prot-http
Graham, all changes to the prot-http sources seems to be authored 
by Carl, I've seen no traces of changes to the protocol introduced 
by Brian.
Graham
21-Feb-2010
[2057]
Andreas and I did the same, doing a diff on the original prot-http 
and current and found no major changes.  Suggest submit a bug report.
BrianH
21-Feb-2010
[2058x2]
DevBase is the forum/filestore that you access withg the CHAT command 
in R3.
I haven't posted changes to the http protocol yet, sorry.
Andreas
21-Feb-2010
[2060x2]
Brian, I guess you are talking about changes that are also not yet 
in R3?
Ah, nevermind. Upon re-reading, I think I misunderstood your message.
BrianH
21-Feb-2010
[2062]
Right. The http scheme is due for a major revamp. What we have is 
not really all that we want.
Graham
21-Feb-2010
[2063]
So we now have two DevBases ?
BrianH
21-Feb-2010
[2064x2]
Technically, the one accessed through CHAT is the third DevBase. 
The other two have been retired.
The first was written by Carl to do /View development, way back when, 
and never released (afaict). DevBase 2 was derived from that, and 
DevBase 3 was based on the lessons learned from 2.
Graham
21-Feb-2010
[2066]
Ok, we need to be more explicit and refer to DevBase3 now
BrianH
21-Feb-2010
[2067x5]
It's the only DevBase now. I just use the term to distinguish from 
CHAT, which is only a mezzanine that calls a DevBase client. Most 
people just call it chat.
So we have the datastore (DevBase), the server (DevBase server), 
a client (DevBase client) and the mezzanine wrapper (CHAT).
For most people those distinctions don't matter, they can just call 
it chat. It matters to me because writing another DevBase client 
is on my immediate todo list.
I client for R2, to be accessed through a CHAT mezzanine in R2.
I -> A
Graham
24-Apr-2010
[2072]
Updated Feb 21 http://github.com/gchiu/Rebol3/tree/master/protocols/
Brock
25-Apr-2010
[2073]
thanks for this Graham
DideC
26-May-2010
[2074x4]
I want to build a very very very simple web server in R3.

I just want to be able to receive an HTTP request and send the response.
But me and Rebol networking are two differents people !!


To begin, I just want to be able to display the full request in the 
response page.

So far I have wrote this by peeking code in DocBase, but it does 
not work as I want : the browser stay awaiting the answer. Can one 
point me to what's wrong ?
REBOL []

print "Serving port 8080..."

open-subport: func [port] [
    print "=== Creating sub-port"
    port/awake: func [event /local port] [
        print ["=== Subport event:" event/type]
        port: event/port
        switch/default event/type [
            read [
                print ["    " data: to-string port/data]

                write port to-binary rejoin ["<html><head></head><body>" data "</body></html>" 
                newline]
                true
            ]
            wrote [read port]
            close [close port]
        ] [false]
    ]
]

server: open tcp://:8080

server/awake: func [event] [
    print ["*** Server event:" event/type]
    if event/type = 'accept [
        open-subport first event/port
    ]
    false
]

wait 30
close server
print "Done serving"
halt
Seems I have found my way to make it working :
REBOL []

print "Serving port 8080..."

open-subport: func [port] [
	print "=== Creating sub-port"
	port/awake: func [event /local port data] [
		print ["=== Subport event:" event/type]
		port: event/port
		switch/default event/type [
			read [
				print ["    " data: to-string port/data]
				data: replace/all data newline <br>

    write port to-binary rejoin ["HTTP/1.0 200 OK^/Content-type: text/html^/^/<html><head></head><body>" 
    data "</body></html>" newline]
			]
			wrote [
				close port
			]
		] [false]
	]
	
	read port
]

server: open tcp://:8080

server/awake: func [event] [
    print ["*** Server event:" event/type]
    if event/type = 'accept [
        open-subport first event/port
    ]
    false
]

wait 30
close server
print "Done serving"
halt
NickA
26-May-2010
[2078]
great!
Andreas
26-May-2010
[2079]
You might also want to have a look at: http://github.com/earl/rebol3/blob/master/scripts/shttpd.r
Anton
27-May-2010
[2080]
Ah, you just forgot the http header.
DideC
27-May-2010
[2081]
Thank's Anton. Can be of some help.
Anton
28-May-2010
[2082]
(DideC meant to thank Andreas.)
NickA
28-May-2010
[2083]
I'm very happy to see this being done with R3 :)