wsgi, ajax, and multiple requests

F

Frank Millman

Hi all

I have a question about wsgi.

As far as I can tell from the spec and from the reference implementation,
wsgi requires that each request from the client is responded to by one or
more headers, followed by the response body. It is then ready to handle the
next request.

99% of the time this is fine, but I have a situation where I need to vary
this, and I cannot see how to do it. Here is the scenario.

I am dabbling with writing an ajax-style app. On occasion, I want to send
more than one message from the client to the server. It is important that
the server processes the messages in the same order that they are generated.
I have found that the Safari browser does not always send them in the
correct sequence.

I found an article on the subject -

http://www.sitepen.com/blog/2009/02/27/deterministic-clientserver-interaction/

It explains that you can never guarantee that the messages will arrive in
the same order, with *any* browser. Maybe I was lucky with the other ones.
It goes on to say that, if the order is important, you must include a header
with a sequential counter, and the server must check the sequence. If
received out of sequence, it must queue the one received, wait for the
correct one, and then process them both in the correct order.

So the question is, how can I achieve this with wsgi? If I detect that I
have received a request out of sequence, I can queue the request, and send
an empty response. When I receive the correct request, I can process it,
call start_response(), and return the response body, but I cannot figure out
how to get back to process the queued request.

Any advice will be much appreciated.

Frank Millman
 
P

Paul Rubin

Frank Millman said:
So the question is, how can I achieve this with wsgi? If I detect that
I have received a request out of sequence, I can queue the request,
and send an empty response.

I don't see how that can help, on the server side. Even if you send the
responses in the right order, they might arrive at the client in the
wrong order. So you have to do the reordering on the client.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top