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

World: r3wp

[!REBOL3 Schemes] Implementors guide

Graham
20-Feb-2010
[2046x2]
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 :)
Graham
28-Jun-2010
[2084x2]
Not sure what's happening here .. but my server closes the connection, 
and termintes the thread, but R3 is not getting a close event.
Hmm...but I get a close event if the server throws an exception
Graham
29-Jun-2010
[2086x2]
db: open jdbcbridge://localhost

  insert db [{select * from staff where fullname = (?)} "Graham Chiu" 
  ]
		>> print length? db 
		1
		result: pick db 1
		>> print length? db
		0
		close db
		db: open jdbcbridge://localhost:8000
		insert db {select first 2 * from staff}
		>> print length? result
		2
		>> result: copy db
		>> print length? result
		0
		close db
http://github.com/gchiu/Rebol3/blob/master/protocols/prot-jdbcbridge.r
Steeve
29-Jun-2010
[2088x2]
I see no evidence in that test. What is the events trace ?
There are potentially several problems in that code.

First, never use wait in the event handler. it's a good way to produce 
a stack overflow.
Second, I have to go to work, sorry...
Graham
29-Jun-2010
[2090]
It's so long since I looked at this R3 network stuff ...
Steeve
29-Jun-2010
[2091]
Last but not least , there is problem in the close event.

>>client/spec/data: load enline to-string client/spec/data
should probably be
>>client/spec/data: load enline to-string client/data
Graham
29-Jun-2010
[2092x4]
except I'm copying the data from client/data to client/spec/data 
...
and then clearing the client/data
I've setup a server at www.compkarori.co.nz:8020 to help debug the 
jdbcbridge protocol.
you don't need any db drivers installed on your side ... it's a tcp 
connection to the db server.