content-length

Simulate Incorrect Content-Length Headers for HTTP in C#

We are building a comprehensive integration test framework in C# for our application which exists on top of HTTP using IIS7 to host our applications. As part of our integration tests we want to test incoming requests which will result in EndOfStreamExceptions ("Unable to read beyond end of stream") that occur when a client sends up a HT...

Content-Length header always zero

I set a header in the following way: header('Content-Length: ' . filesize($strPath)); On my PC with ZendServer it works fine and I can download a file with the correct file size. On the production server, a Solaris with Apache and compiled PHP, I get a file with the file size equal to zero, so an empty file. Is there a config paramet...

[ASP.NET] IIS7 downloading file length

I've following code for file download: FileInfo fileInfo = new FileInfo(filePath); context.Response.Clear(); context.Response.ContentType = "application/octet-stream"; context.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(filePath)); context.Respon...

Get Size of HTTP Response in Java

Hi, 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) feedurl.openConnection(); //check the response for the content-size int feedsize = con.getContentLength(); The problem is, that content-legnth is not always set. E.g. w...

download of large files slow when content-length specified (IIS7)

Hi, I have an asp.net web page to serve large file downloads to users. The page is hosted on IIS7, Windows Server 2008. The strange thing is that users can download at good speeds (2MB/s) when I don't add a content-length response header but as soon as I add this header, download speed drops to somewhere around 35kbps/s. This is the c...

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 to be compliant with HTTP 1.1 specs using persistent connections. I see the advantage of the Content-Length header being : Download dialogs can show ...

How to calculate Content-Length for a file download within Kohana PHP?

I'm trying to send a file from within a Kohana model to the browser, but as soon as I add a Content-Length header, the file doesn't start downloading right away. Now the problem seems to be that Kohana is already outputting buffers. An ob_clean at the begin of the script doesn't help this though. Also adding ob_get_length() to the Conte...

Content-Length header not returned from Pylons response

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-...

How do I calculate the content-length of a file upload in ruby?

I need to include the content-length of a image /png file posted in an upload to a webservice. But how do I calculate the content-length to include in the header? Thanks. I am submitting it using rest-client. The webservice for the upload is Postful: and the documentation has been unclear: http://www.postful.com/developer/guide#upl...

POST data getting lost: Content Length = 0

I've been trying to find a solution for ages with no success. On our app, customers submit a form and on the next page we process it. Sometimes though the data never arrives. This seems to happen for just a few of our customers. Seems to happen with IE7 and using a proxy. Here's some headers, note the HTTP_VIA: X-REWRITE-URL: /process....

IIS7 - Specifying content-length header in ASP causes "connection reset" error

I'm migrating a series of websites from an existing IIS5 server to a brand new IIS7 web server. One of the pages pulls a data file from a blob in the database and serves it to the end user: Response.ContentType = rs("contentType") Response.AddHeader "Content-Disposition", "attachment;filename=" & Trim(rs("docName"))&rs("suffix")' let t...

HTML-Form not Posting? Content-Length: 0 (in HttpFox)

Literally yesterday an application I am developing does not post any form inputs and instead using HttpFox watch tool I am seeing the following as the POST data. Content-Type: application/x-www-form-urlencoded Content-Length: 0 When running the application locally with ASP.NET development server I cannot post the form using any browse...

Most efficient way to determine if a string length != 0?

I'm trying to speed up the following: string s; //--> s is never null if (s.Length != 0) { <do something> } Problem is, it appears the .Length actually counts the characters in the string, and this is way more work than I need. Anybody have an idea on how to speed this up? Or, is there a way to determine if s[0] exists, w/out ch...

C# 4.0, Most efficient way to determine if a string length != 0? Part 2

(My apologies, this is a 2nd post to http://stackoverflow.com/questions/3390175/most-efficient-way-to-determine-if-a-string-length-0 but I can't figure out how to reply to people's answers, my reply becomes posted as an 'answer') Ideally, what I'm looking for is the most efficient algorithm to do the following (which will be called 100m...

Site incredibly slow for firefox, instant on every other browser: KeepAlive issue?

I have a site where a page takes 10 seconds to load with firefox, and a further 10 seconds to load the images. It's a php page running on apache. The Images are just static images. It runs beautifully on chrome.... instant loading. googling for the answer has pointed me towards a possible issue with keep alive and the lack of content l...

Is there any way I can see how long a JQuery AJAX call takes to execute?

Hi folks, Is there anyway to see how long a simple $.getJSON method takes to call using some type of timing code, in jquery/javascript? Secondly, is there any way to see how BIG the response Content-Length is, in kB or megabytes? ...

PHP returning content-length of 0 to python's urllib

My code fetches CSV data from a PHP page using httplib. When I open the page in Firefox or Chrome, the data displays just fine. However, when I try to fetch it with my python code, I get a header with content-length: 0 and no data. This page is the only one that does this - in another page in the same directory, the python httplib fetchi...

Empty Content returned from Web Server (Big/IP+IIS7)

Occasionally, individual users will receive "blank pages" from our web server on login. It only happens to individual users, not all users at a given time. Using the same account from a different machine may or may not reproduce the problem. Using a different account from the same machine usually works. The problem will often go away o...

Is it OK to send an HTTP response with file attachment without specifying the Content-Length?

Meaning will it work fine? I have a situation where I am attaching files via HTTP attachment by attaching the URI of the file and it is on a different server so I don't have access to the length of the file. ...

Can I add file size to Builder XML output

I'm working on a ruby on rails app that generates a large XML document using a builder template, but I've hit a bit of a stumbling point. The XML output must have a field that contains the file size in bytes. I think that I'll basically need to use the value that would populate the "Content-Length" header in the http response, but updat...