473,803 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

urllib2 and transfer-encoding = chunked

I am having errors which appear to be linked to a previous bug in
urllib2 (and urllib) for v2.4 and v2.5 of Python. Has this been fixed?
Has anyone established a standard workaround? I keep finding old
posts about it, that basically give up and say "well it's a known bug."
Any help would be greatly appreciated.

Jan 18 '07 #1
3 5980
<jd****@gmail.c omescribió en el mensaje
news:11******** **************@ l53g2000cwa.goo glegroups.com.. .
>I am having errors which appear to be linked to a previous bug in
urllib2 (and urllib) for v2.4 and v2.5 of Python. Has this been fixed?
Has anyone established a standard workaround? I keep finding old
posts about it, that basically give up and say "well it's a known bug."
Any help would be greatly appreciated.
Perhaps if you said what the supposed error is...

--
Gabriel Genellina
Jan 18 '07 #2
Haha! My mistake.

The error is that when a web server is chunking a web page only the
first chunk appears to be acquired by the urllib2.urlopen call. If you
check the headers, there is no 'Content-length' (as expected) and
instead there is 'transfer-encoding' = 'chunked'. I am getting about
the first 30Kb, and then nothing else.

I don't get a ValueError like described at the following post:

http://groups.google.com/group/comp....3ea9ca84b28669

Here's the code that I think is failing, it's basically textbook Python
for accessing a url:

file = urllib2.urlopen (url)
contenttype = file.info().typ e
if contenttype and contenttype.fin d('text') -1:
return file.read()
#
# I am checking the content type because I don't want to download
..jpegs and the like
#

I have typed similar commands into the interpreter, which also produces
only about the first 30KB of the url.

Sorry for the confusion.

Gabriel Genellina wrote:
<jd****@gmail.c omescribió en el mensaje
news:11******** **************@ l53g2000cwa.goo glegroups.com.. .
I am having errors which appear to be linked to a previous bug in
urllib2 (and urllib) for v2.4 and v2.5 of Python. Has this been fixed?
Has anyone established a standard workaround? I keep finding old
posts about it, that basically give up and say "well it's a known bug."
Any help would be greatly appreciated.

Perhaps if you said what the supposed error is...

--
Gabriel Genellina
Jan 18 '07 #3
In article <11************ **********@51g2 000cwl.googlegr oups.com>,
jd****@gmail.co m wrote:
Haha! My mistake.

The error is that when a web server is chunking a web page only the
first chunk appears to be acquired by the urllib2.urlopen call. If you
check the headers, there is no 'Content-length' (as expected) and
instead there is 'transfer-encoding' = 'chunked'. I am getting about
the first 30Kb, and then nothing else.

I don't get a ValueError like described at the following post:
Hi jdvolz,
What error *do* you get? Or is it that no error is raised; you're just
not getting all of the data? If it is the latter, then the sending
server might be at fault for not properly following the chunked transfer
protocol. One way to find out would be to fire up Ethereal and see
what's coming down the wire.
I am having errors which appear to be linked to a previous bug in
urllib2 (and urllib) for v2.4 and v2.5 of Python. Has this been fixed?
Has anyone established a standard workaround? I keep finding old
posts about it, that basically give up and say "well it's a known bug."
Can you give us some pointers to some of these old posts? And tell us
what version of Python you're using.

--
Philip
http://NikitaTheSpider.com/
Whole-site HTML validation, link checking and more
Jan 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3965
by: Matthew Wilson | last post by:
I am writing a script to check on my router's external IP address. My ISP refreshes my IP very often and I use dyndns for the hostname for my computer. My Netgear mr814 router has a webserver that uses HTTP basic authorization. My script uses urllib2 to connect to the router and read the html page with the current external IP address. This is the function I wrote to lookup the router's external IP: def mr814(router_user,...
0
1136
by: mw | last post by:
Hi, I get an error when trying to use urllib2 with the ftp daemon of publicfile: $ python Python 2.2.3 (#1, Oct 15 2003, 23:33:35) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import ftplib
2
6121
by: John F Dutcher | last post by:
Can anyone comment on why the code shown in the Python error is in some way incorrect...or is there a problem with Python on my hoster's site ?? The highlites don't seem to show here...but line #80 and line # 38 are the first line offenders. --> --> -->
0
2659
by: jacob c. | last post by:
When I request a URL using urllib2, it appears that urllib2 always makes the request using HTTP 1.0, and not HTTP 1.1. I'm trying to use the "If-None-Match"/"ETag" HTTP headers to conserve bandwidth, but if I'm not mistaken, these are HTTP 1.1 headers, so I can't reasonably expect a web server to respond correctly to my requests. (In my limited testing, it looks like some servers respond correctly with an HTTP 304 status, while some...
3
3601
by: Artificial Life | last post by:
urllib2 does not seem to be able to handle META-REFRESH in an html document. I just get back the html to the page that is supposed to forward me to the intended page. Any way around this?
0
1865
by: Gil Tal | last post by:
Hi, I use urllib2 to download a redirected url and I get an exception from the bowels of urllib2. It seems that urllib2 implements some super sophisticated self check and tries to control the access to attributes using lots of calls to hasattr(the builtin function) and a custom __getattr__() on the Request class that perfroms some checks and raises an AttributeError if it's not happy. The problem is that hasattr() according to the docs is...
1
3374
by: Ray Slakinski | last post by:
Hello, I have defined a function to set an opener for urllib2, this opener defines any proxy and http authentication that is required. If the proxy has authencation itself and requests an authenticated file I get a HTTP status code of 401 (Unauthorized access of the file being requested) I do see in the headers the Proxy-authorization and the Authorization headers being sent for the request.
0
2453
by: Ali.Sabil | last post by:
hello all, I just maybe hit a bug in both urllib and urllib2, actually urllib doesn't support proxy authentication, and if you setup the http_proxy env var to http_proxy=http://user:passwd@host:port/ and https_proxy=$http_proxy i get a traceback : Traceback (most recent call last): File "test_urllib.py", line 2, in ? urllib.urlopen("https://sf.net/")
3
10212
by: m.banaouas | last post by:
Hi all, I started to use urllib2 library and HTTPBasicAuthHandler class in order to authenticate with a http server (Zope in this case). I don't know why but it doesn't work, while authenticating with direct headers manipulation works fine! WinXP Sp2 Python 2.4.4 Thanks in advance for your help/comments
1
5762
by: Alessandro Fachin | last post by:
I write this simply code that should give me the access to private page with htaccess using a proxy, i don't known because it's wrong... import urllib,urllib2 #input url url="http://localhost/private/file" #proxy set up
0
9699
marktang
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...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10309
jinu1996
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...
1
10289
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9119
agi2029
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...
1
7600
isladogs
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...
0
6840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2968
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.