it's a good suggestion and one I have not tried. Thanks I'll give it
a try and report back.
Kee
On Oct 10, 2006, at 10:59 AM, Jan Schenkel wrote:
--- kee nethery <[EMAIL PROTECTED]> wrote:
I am using Andre Garzia's wonderful RevHTTPd code to
create a small
slave server to provide a service for other master
servers. In
general it works well except, one of the master
servers does
something funny but totally legit when it sends a
POST to the slave
RevHTTPd server and most times the RevHTTPd server
deals with it, and
sometimes not. This is a read from socket question
and I could use help.
[snip]
The slave server code is very simple:
on httpStart
accept connections on port 8080 with message
"newConnection"
end httpStart
on newConnection pSocketID
read from socket pSocketID with message
"processRequest"
-- message is actually doing a "processRequest
pSocketID,it" where
it contains all the data gathered by the socket.
end newConnection
on processRequest pSocketID, pSocketData
global theSocketData
put pSocketData into theSocketData
-- then from here on down it parses theSocketData
and does a reply
to the master server
Hi Kee,
While I was building the database router server app
that I showed at RevConWest, I encountered similar
problems. Try something like this:
local sSocketDA -- data array
on httpStart
accept connections on port 8080 \
with message "newConnection"
end httpStart
on newConnection pSocketID
read from socket pSocketID until CRLF \
with message "ReadRequest"
end newConnection
on ReadRequest pSocketID, pSocketData
put pSocketData into sSocketDA[pSocketID,"request"]
read from socket pSocketID until CRLF & CRLF \
with message "ReadHeaders"
end ReadRequest
on ReadHeaders pSocketID, pSocketData
put pSocketData into sSocketDA[pSocketID,"headers"]
read from socket pSocketID until empty \
with message "ProcessRequest"
end ReadHeaders
on processRequest pSocketID, pSocketData
global theSocketData
put sSocketDA[pSocketID,"request"] & CRLF & \
sSocketDA[pSocketID,"headers"] & CRLF & CRLF & \
pSocketData into theSocketData
-- ... carry on and process ...
end processRequest
##
This approach seems to give the sockets breathing
room. For extra safety, you could parse the headers,
look for the Content-length header and read from the
socket 'for x chars' instead of 'until empty'.
Don't forget to clean up the data in the array after
you've written back the result, of course ;-)
Hope this helped,
Jan Schenkel.
Quartam Reports for Revolution
<http://www.quartam.com>
=====
"As we grow older, we grow both wiser and more foolish at the same
time." (La Rochefoucauld)
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution