content-length

When does Rails respond with 'transfer-encoding' vs. 'content-length'?

岁酱吖の 提交于 2019-11-29 10:46:13
I'm building an API on Rails version 4.1.7/Nginx that responds to request from an iOS app. We're seeing some weird caching on the client and we think it has something to do with a small difference in the response that Rails is sending back. My questions... 1) I want to understand why, for the exact same request (with only the Authorization header value changed), Rails sends back transfer-encoding: chunked sometimes and Content-Length: <number> sometimes? I thought that maybe it had something to do with the response size, but in the example responses whose headers I've pasted below, the data

HTTP POST: content-length header required?

五迷三道 提交于 2019-11-29 05:25:00
I'm currently trying to optimize http-based data transfer between several applications. Our current approach, downloading first and then creating the post-request, obviously add extra IO/memory load and latencies, which I'd like to circumvent. The core question of all: Is it required to send a "Content-Length" header in HTTP POST requests? IIRC, HTTP 2616 declares that it's optional, but I'm not sure how applications actually behave at this point. Depends what you mean by optional. If you mean that you can just omit the header anytime you like then no, it is not optional. The HTTP spec has

Get file size from multipart form upload Content-Length header

拈花ヽ惹草 提交于 2019-11-29 03:44:43
So, I'm uploading a file, and then downloading it... but the Content-Length in the upload headers do not match the file size. I'm guessing there is some other data involved with this calculation and transfer, but what exactly? How do I get an accurate file size from the Content-Length? Is it even possible? I know there are the boundaries, and maybe some other things, but check it: 5380216 - 5379906 = 310 "----WebKitFormBoundaryeoFyqD4zr6smwYDG".size → 38 So the boundary size is 38... 310 has some LCDs of 5, 10, 31... those don't work well with 38 in any way... I'm lost! File sizes: -rw-r--r--@

How to set content-length in android?

断了今生、忘了曾经 提交于 2019-11-28 14:36:00
I want to get content size by request.getContentLength() in server client JSP page. But request.getContentLength() always return -1, i do not why? Android snippet code: URL uri = new URL(actionUrl); HttpURLConnection conn = (HttpURLConnection) uri.openConnection(); //conn.setChunkedStreamingMode(100); conn.setConnectTimeout(setTimeOut>0?setTimeOut:timeoutConnection); conn.setReadTimeout(setTimeOut>0?setTimeOut:timeoutConnection); conn.setDoInput(true); conn.setDoOutput(true); conn.setUseCaches(false); conn.setRequestMethod("POST"); conn.setRequestProperty("Connection", "keep-alive"); //conn

How to get the file size of a remotely stored image? (php)

ⅰ亾dé卋堺 提交于 2019-11-28 08:56:18
问题 Let's say we have an image file, stored in a remote server (for example, let's take this image), how can we determine (in PHP code) it's file size? If the file was on server, we would have used filesize (see here), but this wouldn't work on a remote file (see here). The other alternative is to check for the "Content-Length", but I believe it wouldn't work for an image file (see here) I would like for a solution like the one given here (e.g, something like: <?php function get_remote_size($url)

Node Express Content-Length

不羁岁月 提交于 2019-11-28 06:53:16
I use node.js and express at a small project. I set response header like blow: res.set({'Content-Type':'text/plain;charset=utf-8', 'Content-Length': Buffer.byteLength(data, 'utf-8')}); I can use console.log print data's length is 317. But at browser's console, I just get these: Connection:keep-alive Content-Encoding:gzip Content-Type:text/plain;charset=utf-8 Date:Sat, 01 Jun 2013 08:21:59 GMT Transfer-Encoding:chunked Vary:Accept-Encoding X-Powered-By:Express So, why the content-length disappeared? Myrne Stol The response has Transfer-Encoding: chunked . Here Content-Length is not applicable,

Content-Length header always zero

二次信任 提交于 2019-11-28 05:41:53
问题 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 parameter? Something that can prevent to set 'Content-Length: 1222'? Thanks. The code: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); require 'includes

When does Rails respond with 'transfer-encoding' vs. 'content-length'?

China☆狼群 提交于 2019-11-28 03:47:50
问题 I'm building an API on Rails version 4.1.7/Nginx that responds to request from an iOS app. We're seeing some weird caching on the client and we think it has something to do with a small difference in the response that Rails is sending back. My questions... 1) I want to understand why, for the exact same request (with only the Authorization header value changed), Rails sends back transfer-encoding: chunked sometimes and Content-Length: <number> sometimes? I thought that maybe it had something

HTTP POST: content-length header required?

核能气质少年 提交于 2019-11-27 22:55:35
问题 I'm currently trying to optimize http-based data transfer between several applications. Our current approach, downloading first and then creating the post-request, obviously add extra IO/memory load and latencies, which I'd like to circumvent. The core question of all: Is it required to send a "Content-Length" header in HTTP POST requests? IIRC, HTTP 2616 declares that it's optional, but I'm not sure how applications actually behave at this point. 回答1: Depends what you mean by optional. If

Get file size from multipart form upload Content-Length header

て烟熏妆下的殇ゞ 提交于 2019-11-27 22:11:20
问题 So, I'm uploading a file, and then downloading it... but the Content-Length in the upload headers do not match the file size. I'm guessing there is some other data involved with this calculation and transfer, but what exactly? How do I get an accurate file size from the Content-Length? Is it even possible? I know there are the boundaries, and maybe some other things, but check it: 5380216 - 5379906 = 310 "----WebKitFormBoundaryeoFyqD4zr6smwYDG".size → 38 So the boundary size is 38... 310 has