Hi -
I'm writing some Python code to interact with Amazon's S3 service. One
feature of S3 is that it will allow you to use the HTTP HEAD request to
retrieve metadata about an S3 object without actually retrieving the
content of the object. In trying to use this feature, I'm running into
what I think is a bug in httplib.py.
If the resource I perform the HEAD request on exists within S3 then
everything is fine. If, however, the resource doesn't exist then a 404
is returned. If the request had been a GET rather than a HEAD the body
of the response would be some XML that gave further information about
the error status returned. However, for a HEAD request no body can be
returned so the body is empty. The error response, for either HEAD or
GET, does include the following header:
transfer-encoding: chunked
And this seems to be causing confusion in httplib.py. I have to call
the read method of the response or else I get a ResponseNotRead y
exception on my next request. When I attempt to read the body of the
error response to the HEAD request it is passed onto the _read_chunked
method where it immediately tries to do a readline() on the connection
which, of course, hangs because no body has been sent in the response.
So, I know this is kind of a boundary condition and perhaps it hasn't
come up before but it seems that the behavior of httplib is incorrect.
I think something needs to be added to the _read_chunked method which
checks if the request is a GET and, if so, just reads zero bytes from
the socket and returns.
Any comments? Thanks,
Mitch 1 3073
For what it's worth, I made the following change to httplib.py and it
seems to have solved my problems:
c455
< if self.chunked:
--- if self.chunked and self._method != 'HEAD':
I'm using Python 2.4.1 on MacOS.
Mitch This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: hitectahir |
last post by:
Hi,
I have been using a remote data server named Clarens which runs on top
of the Apache web server and communicates through xmlrpc on Redhat
Linux 7.3. It has been working fine for about a month, but today it
has started giving some error in httplib.py. The complete traceback is
given below:
Traceback (most recent call last):
File "clarensclient.py", line 2, in ?
|
by: Roger Binns |
last post by:
I have just spent several weeks mashing xmlrpc, httplib and SSL (from
M2Crypto) to work together. The current standard library has several
problems:
- Builtin SSL is pretty much useless if you actually care
about security
- Poor HTTP authentication support
- No server side stuff (SSL, HTTP authentication etc)
- Pathological coding to ensure that at most one request is
sent on a connection, rather than reusing an already open
|
by: scummer |
last post by:
Hi,
I am having a problem with the httplib HTTPConnection object. While I
can easily send requests that don't have any payload (ie. "get"), I
encounter issues if I want to post xml data. If you look at the class
below, when req == 'getFreeBusyInfo' all functions perfectly, but when
req == 'conflictRequest' I run into problems of the nature "400 Bad
Request". As you will notice, I also tried the shorter HTTPConnection
instance method...
|
by: Milos Prudek |
last post by:
How can I set httplib timeout for httplib.request() ?
httplib.request timeouts after 3:10 with "socket" timeout error message.
I found socket.settimeout() and I believe there is a way to add
".settimeout()" function to httplib without hacking httplib source.
Is it possible?
--
|
by: Terry Kerr |
last post by:
Hi,
I have an app that makes a https POST to a remote server that I have no
control over. The app runs fine in python 2.1.3 with socket.ssl
compiled with openssl-0.9.6, however it will not run in python 2.3.3
compiled with openssl-0.9.7d. The script below demonstrates the problem.
============================================
import httplib
path = "/cmaonline.nsf/ePayForm?OpenForm"
| |
by: Laszlo Zsolt Nagy |
last post by:
Hello,
This is from the docs, from section 11.6.1 (HTTPConnection Objects)
HTTPConnection instances have the following methods:
request( method, url])
The headers argument should be a mapping of extra HTTP headers to send with the request.
|
by: spamsink42 |
last post by:
this code
h=httplib.HTTPConnection('euronext.com')
h.request('GET',
'http://www.euronext.com/home/0,3766,1732,00.html')
fails with this message
File "httplib.py", line 532, in connect
socket.SOCK_STREAM):
|
by: Baptiste Lepilleur |
last post by:
I activated httplib debug, and when trace are printed, a UnicodeError
exception is thrown. I have already set sys.stdout to use utf-8 encoding
(this removed the exception when *I* was printing unicode), but from the
stacktrace below, the encoding seems to magically have switched to 'ascii'
when httplib does the printing...
import codecs
import sys
sys.stdout = codecs.getwriter("utf-8")(sys.__stdout__)
....
|
by: shonen |
last post by:
I'm currently attempting to connect to a shoutcast server
pull down the information from here and then I'll parse it.
I got this working with the httplib, which was great, the problem is I want to use the select statement to do only do this periodically. (I'm trying to be a client, accepting data, that might be my first problem)
Basically this is the code that im working on to TEST to mimic what the httplib does, only return a socket...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |