» Content-Length header not returned from Pylons response
Content-Length header not returned from Pylons response
|May 6, 2010
Posted by forumadmin
I’m still struggling to Stream a file to the HTTP response in Pylons. In addition to the original problem, I’m finding that I cannot return the Content-Length header, so that for large files the client cannot estimate how long the download will take. I’ve tried
response.content_length = 12345
and I’ve tried
response.headers['Content-Length'] = 12345
In both cases the HTTP response (viewed in Fiddler) simply does not contain the Content-Length header. How do I get Pylons to return this header?
(Oh, and if you have any ideas on making it stream the file please reply to the original question – I’m all out of ideas there.)
Edit: while not a generic solution, for serving static files
FileApp allows sending the Content-Length header. For dynamic content it looks like Alex Martelli‘s answer is the only option.
More Related Questions
- Content-Length header versus chunked encoding I'm trying to weigh the pros and cons of setting the Content-Length HTTP header versus using chunked encoding to return [possibly] large files from my server. One or the other is needed […]
- what is relation between content-length and byte ranges in HTTP/1.1? I am not grasping the idea behind content-length and byte ranges as specified by HTTP 1.1
Is there are connection between the two of some sort? If a client requests in terms of byte […]
- Python Image Uploading with AjaxUpload I'm trying to use AjaxUpload with Python:
I would like to know how to access the uploaded file with Python. On the web site, it says:
* PHP: […]
- How do I use beaker caching in Pyramid? I have the following in my ini file:
cache.regions = default_term, second, short_term, long_term
cache.type = memory
cache.second.expire = 1
cache.short_term.expire = […]
- Python Webframework Confusion Could someone please explain to me how the current python webframworks fit together?
The three I've heard of are CherryPy, TurboGears and Pylons. However I'm confused because TurboGears […]
- What is the maximum length of a URL in different browsers? What is the maximum length of a URL in different browsers? Does it differ between browsers?
Does the HTTP protocol dictate it? Asked By - Sander […]
- Get Size of HTTP Response in Java I would like to know how much data was sent in response to a certain http-request.
What I currently do is this:
HttpURLConnection con = (HttpURLConnection) […]
- How do I get the content length of a Django response object? In Django, I try to logging the request and response content length, which exactly the same as what Django server prints to stderr.
[05/Apr/2011 22:59:08] "GET /pages/ HTTP/1.1" 200 […]
- Is it possible to set blob download sizes in GAE apps now that the Content-Length header is disallowed? After the AppEngine API update that came out a few weeks ago, the wonderful "Disallowed HTTP Response Headers" section appeared in the Python Response class documentation here, which […]
- How do I make Flask stream a static file with HTTP 206 Partial Content? I want to use a looping video on a site made powered by Flask. Apparently, Chrome will not loop the video, unless it was streamed with an HTTP 206 code being returned. Flask, however, […]