Thanks to you both. I'll read up on sockets, but it seems unlikely that it works the way I thought it might...

On Aug 12, 2008, at 8:45 PM, Kent Johnson wrote:

On Tue, Aug 12, 2008 at 7:27 AM, Eric Abrahamsen
<[EMAIL PROTECTED]> wrote:

On Aug 11, 2008, at 6:54 PM, Kent Johnson wrote:
I'm not sure if you want to see the traffic coming in from your users,
or the traffic from your server to the third-party server. I don't
know what kind of interaction you want, either.

I'd like to be able to see the response coming back from the third- party server, and have lighttpd check its headers and either intercept it or allow it back into the framework. Say if it's got a text content-type then let it in to the framework, and if it's got an image content-type then ignore it or throw it away. Rephrasing it this way makes it sound pretty unlikely. I guess what I wanted was a better sense of how urllib2 uses a socket to make the request, and how the response, on its way back to my server, finds that socket. I thought that if the socket file was something that hung around between requests, I might be able to configure lighttpd to 'listen in' on that socket, and grab the response if it met certain criteria. But if that
were possible then urllib2 would raise an error, right?

lighttpd will not see the traffic to the third-party server; the tp
server is not making a request of lighttpd; your code is making a
request of it. The response comes back on the same socket that was
opened by the request; if you want to know how they match up you will
have to learn about TCP/IP which is the underlying network protocol.
This might help:
http://www.amk.ca/python/howto/sockets/

If you want to filter the response according to the headers, you can
do that in your code. The response object returned by urllib2 includes
an info() method that gives access to the response headers.

Kent

PS Please Reply All to reply to the list.

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to