HTTP getreply() never returns

M

Marko.Cain.23

Hi,

I have the following code which send/receive HTTP request/response:

# where sampleUrl is '127.0.0.1' and
# url is 'www.cnn.com'

h = httplib.HTTP(self.sampleUrl, 8080)
h.putrequest('GET', '/sample?url=' + self.url)
h.endheaders()

errcode, errmsg, headers = h.getreply()

But it never returns from h.getreply().

I am using python 2.3.4. Can you please tell me what am I missing?
I am sure the url is correctly. I try putting this 'http://
127.0.0.1:8080/sample?url=www.cnn.com' and it works.

Thank you for any help.
 
S

Steve Holden

Hi,

I have the following code which send/receive HTTP request/response:

# where sampleUrl is '127.0.0.1' and
# url is 'www.cnn.com'

h = httplib.HTTP(self.sampleUrl, 8080)
h.putrequest('GET', '/sample?url=' + self.url)
h.endheaders()

errcode, errmsg, headers = h.getreply()

But it never returns from h.getreply().

I am using python 2.3.4. Can you please tell me what am I missing?
I am sure the url is correctly. I try putting this 'http://
127.0.0.1:8080/sample?url=www.cnn.com' and it works.

Thank you for any help.
['text/html']

The above shows you the basics of using httplib - if your own server
isn't responding that's probably not the library's fault. What is the
server? Perhaps its implementation of the HTTP protocol is slightly off,
but not so far off that browsers can't work with it.

For what it's worth you *do* appear to have formed the calls correctly,
so something a little more complex is going on here.

You might consider using WireShark (nee Ethereal) to look at the data
passing across the wire when you use the browser and when you use
httplib then comparing the data. That won't work on Windows because it
disobligingly refuses to let you tap into the loopback (127) network.

regards
Steve
 
M

Marko.Cain.23

I have the following code which send/receive HTTP request/response:
# where sampleUrl is '127.0.0.1' and
# url is 'www.cnn.com'
h = httplib.HTTP(self.sampleUrl, 8080)
h.putrequest('GET', '/sample?url=' + self.url)
h.endheaders()
errcode, errmsg, headers = h.getreply()
But it never returns from h.getreply().
I am using python 2.3.4. Can you please tell me what am I missing?
I am sure the url is correctly. I try putting this 'http://
127.0.0.1:8080/sample?url=www.cnn.com'and it works.
Thank you for any help.
['text/html']

The above shows you the basics of using httplib - if your own server
isn't responding that's probably not the library's fault. What is the
server? Perhaps its implementation of the HTTP protocol is slightly off,
but not so far off that browsers can't work with it.

For what it's worth you *do* appear to have formed the calls correctly,
so something a little more complex is going on here.

You might consider using WireShark (nee Ethereal) to look at the data
passing across the wire when you use the browser and when you use
httplib then comparing the data. That won't work on Windows because it
disobligingly refuses to let you tap into the loopback (127) network.

regards
Steve


Thanks. I run the same script hits the same server (a tomcat server):
One is on Fedora 5 with python 2.4, this works.
But one is on Red Hat 4 with python 2.3, this one does not work.

Can you please tell me how can I make the script works on RHEL 4
without upgrading it to python 2.3?
 
S

Steve Holden

Hi,
I have the following code which send/receive HTTP request/response:
# where sampleUrl is '127.0.0.1' and
# url is 'www.cnn.com'
h = httplib.HTTP(self.sampleUrl, 8080)
h.putrequest('GET', '/sample?url=' + self.url)
h.endheaders()
errcode, errmsg, headers = h.getreply()
But it never returns from h.getreply().
I am using python 2.3.4. Can you please tell me what am I missing?
I am sure the url is correctly. I try putting this 'http://
127.0.0.1:8080/sample?url=www.cnn.com'and it works.
Thank you for any help.
[...]

For what it's worth you *do* appear to have formed the calls correctly,
so something a little more complex is going on here.

You might consider using WireShark (nee Ethereal) to look at the data
passing across the wire when you use the browser and when you use
httplib then comparing the data. That won't work on Windows because it
disobligingly refuses to let you tap into the loopback (127) network.

regards
Steve


Thanks. I run the same script hits the same server (a tomcat server):
One is on Fedora 5 with python 2.4, this works.
But one is on Red Hat 4 with python 2.3, this one does not work.

Can you please tell me how can I make the script works on RHEL 4
without upgrading it to python 2.3?
I can't see anything in

http://svn.python.org/view/python/trunk/Lib/httplib.py?rev=54581&view=log

that screams it might have fixed a problem. But I'd be tempted to try
and "borrow" a copy of 2.4's httplib, run your program with that in a
directory where it will be found before the standard library 2.3 module
and see if it fixes the problem.

If so, would it be a usable workaround just to use the 2.4 httplib for
that one program?

regards
Steve
 
M

Marko.Cain.23

(e-mail address removed) wrote:
Hi,
I have the following code which send/receive HTTP request/response:
# where sampleUrl is '127.0.0.1' and
# url is 'www.cnn.com'
h = httplib.HTTP(self.sampleUrl, 8080)
h.putrequest('GET', '/sample?url=' + self.url)
h.endheaders()
errcode, errmsg, headers = h.getreply()
But it never returns from h.getreply().
I am using python 2.3.4. Can you please tell me what am I missing?
I am sure the url is correctly. I try putting this 'http://
127.0.0.1:8080/sample?url=www.cnn.com'andit works.
Thank you for any help. [...]
For what it's worth you *do* appear to have formed the calls correctly,
so something a little more complex is going on here.
You might consider using WireShark (nee Ethereal) to look at the data
passing across the wire when you use the browser and when you use
httplib then comparing the data. That won't work on Windows because it
disobligingly refuses to let you tap into the loopback (127) network.
regards
Steve
Thanks. I run the same script hits the same server (a tomcat server):
One is on Fedora 5 with python 2.4, this works.
But one is on Red Hat 4 with python 2.3, this one does not work.
Can you please tell me how can I make the script works on RHEL 4
without upgrading it to python 2.3?

I can't see anything in

http://svn.python.org/view/python/trunk/Lib/httplib.py?rev=54581&view...

that screams it might have fixed a problem. But I'd be tempted to try
and "borrow" a copy of 2.4's httplib, run your program with that in a
directory where it will be found before the standard library 2.3 module
and see if it fixes the problem.

If so, would it be a usable workaround just to use the 2.4 httplib for
that one program?

Thanks. Can you please tell me how can I 'borrow' a copy of 2.4
httplib and run that in 2.3?
 
S

Steve Holden

(e-mail address removed) wrote: [about httplib problems]

If so, would it be a usable workaround just to use the 2.4 httplib for
that one program?

Thanks. Can you please tell me how can I 'borrow' a copy of 2.4
httplib and run that in 2.3?
The easiest way is just to drop it in the directory that contains the
Python program you are running - that should make it available in
preference to the 2.3 library version:

sholden@bigboy ~
$ cat Projects/Python/httplib.py
print "My Own Library!"

sholden@bigboy ~
$ cat Projects/Python/test24.py
import httplib
print "I just imported something"

sholden@bigboy ~
$ python Projects/Python/test24.py
My Own Library!
I just imported something

sholden@bigboy ~
$ rm Projects/Python/httplib.py* # remember the .pyc!

sholden@bigboy ~
$ python Projects/Python/test24.py
I just imported something

sholden@bigboy ~
$

regards
Steve
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top