Correct way to cancel a server-side request?



Hi.

(I search the archives but didn't see anything obvious. Sorry if this
is a repeat question.)

I have a Soup.Server that accepts long-poll requests
(http://en.wikipedia.org/wiki/Push_technology#Long_polling) and it
wants to be able to cancel the request after a timeout period of
around 3-5 minutes.

Essentially the client goes:

GET /next

and the server calls server.pause_message(). A separate mechanism
populates the message and calls unpause_message() when new content
does show up.

If no new content shows up within the timeout period, I want the server
to cancel the request and consequently disconnect the client.

On the client-side there are Session methods to cancel a request but
there is nothing obvious on the server side. At least to me.

What I ended up doing makes me a little nervous, so I want to know
whether it's safe and right.

What I do is to call ClientContent->get_socket->disconnect() which
ultimately causes Soup.Server to raise a request-aborted signal which
is fine.

What I want is a guaranteed way of canceling the connection so
calling unpause_message() is inappropriate as it relies on the client
consuming the response which is outside of my control.

Question: Is .disconnect() the best/only way to do this?


Mark.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]