http-chunked

How To Stream Chunked Response With Spring Boot @RestController

纵饮孤独 提交于 2020-12-05 11:07:21
问题 I have spent like a day on this and I am unable to find a solution that works. In our application we have a couple of endpoints that can return large responses. I have been trying to find a mechanism that allows us to stream the response as we process the result of a database query. The main goals are to limit peak memory usage (not need the entire response in memory) on the service side and to minimize the time to first byte of response (the client system has a timeout if the response doesn

Does Fetch's Response.body chunks correspond to HTTP chunks?

橙三吉。 提交于 2020-01-05 04:38:29
问题 I'm doing a Fetch-api request where the server replies using the HTTP chunked transfer encoding (with text data). I'm consuming the data using the Response.body as a stream. I'm wondering: Is it safe to assume that the chunks generated by the stream correspond to the HTTP chunks? I've seen some questions[1-3] where this assumption seems to be made, but I cannot find anything about this in the spec. [1] JS Fetch use Chunked Transfer Encoding (translating curl to Fetch) [2] Consuming chunked

What response header should HTTP HEAD method get for a dynamically generated file?

怎甘沉沦 提交于 2020-01-03 06:04:28
问题 The http spec says about the HEAD request: The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request. And also: The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD method, the size of the

Java: How to download chunked content correctly?

我只是一个虾纸丫 提交于 2019-12-23 17:33:35
问题 I have to download file which HTTP response is "Transfer-Encoding: Chunked", because of what I can't to «getContentLength» to allocate new bytes buffer for DataInputStream. Can you advice me how to do it correctly? Code example is very simple: try { dCon = (HttpURLConnection) new URL(torrentFileDownloadLink.absUrl("href")).openConnection(); dCon.setRequestProperty("Cookie", "session=" + cookies.get("session")); dCon.setInstanceFollowRedirects(false); dCon.setRequestMethod("GET"); dCon

HTTP Content-Length and Chunked Transfer-Encoding. Is there a 2GB Limit?

一笑奈何 提交于 2019-12-19 04:07:41
问题 Is a HTTP Content-Length over 2GB or 4GB supported by modern webservers? How about the chunks in HTTP Chunked Transfer Encoding? Can an individual HTTP chunk exceed 2GB in length? I need to know to use 32-bit integers or 64-bit integers in my code. 回答1: From what I have gathered, 64-bit limits are new, especially in the web browsers. Chrome supports them, Opera maybe, and I see a patch for Firefox that hasn't landed yet. I've read posts that say IE returns negative Content-Length , which

Response sent in chunked transfer encoding and indicating errors happening after some data has already been sent

徘徊边缘 提交于 2019-12-17 16:57:37
问题 I am sending large amount of data in my response to the client in chunked transfer encoding format. How should I be dealing with any errors that occur midway during writing of the response? I would like to know if there is any HTTP Spec recommended practice regarding this for clients to know that indeed the response is not a successful one but that the server ran into some issue. 回答1: Once you have started sending the HTTP headers to the client, you can't send anything else. You have to

Why are POSTs and PUTs ReadAsAsync() null, but ReadAsStringAsync() filled? AKA “How do I turn Chunking Off?”

ぐ巨炮叔叔 提交于 2019-12-12 01:45:42
问题 I have a Web API project that has a few dozen RESTful methods, split about evenly between GETs, POSTs and PUTs. The system uses Entity Framework objects and Newtonsoft's JSON from Nuget (version 9.0.1). Something I've done recently has suddenly broken all the POSTs and PUTs. I find that the [FromBody] objects I'm POST/PUTting arrive as null. So my "Update User" method looks like so... [HttpPut] public IHttpActionResult Put([FromBody] User user) ...but "user" always arrives null. Likewise if I

Changing Netty 4 HTTP File Server example to use ChunkedStream instead of ChunkedFile

与世无争的帅哥 提交于 2019-12-08 02:49:40
问题 I'm trying to wrap my head around Netty 4 way of implementing a HTTP Server that serve HttpResponses bodies using chunked transfer-encoding when total data size is unknown. As a starting point, I simply changed the HttpStaticFileServerHandler (found in https://github.com/netty/netty/tree/netty-4.0.0.CR1/example/src/main/java/io/netty/example/http/file) to use a ChunkedStream instead of a ChunkedFile (they both are ChunkedByteInputs). I understand that it is not ideal in the original example

HTTP 1.1 - Can a client request that transfers not be “chunked”?

雨燕双飞 提交于 2019-12-03 20:48:46
问题 Is it possible for a HTTP 1.1 client to set a header value that indicates the responses to requests should not be chunked? Or is the only way to prevent this, is to send a HTTP 1.0 request? I've tried googling around, but all I can find is ways to disable chunked transfers on HTTP 1.1 servers, so I am guessing it is not possible on a client, but I thought I'd ask anyways. 回答1: In HTTP (starting with HTTP/1.1), recipients MUST support chunked encoding. See http://greenbytes.de/tech/webdav

Handle chunked data sent by Play scala with AngularJs

南笙酒味 提交于 2019-12-03 13:48:42
问题 I send chunked data with Play Scala 2.2 to the client side like this : Ok.chunked(data) I would like to use them as soon as they are available on the client side. If I just get the data and print them on .success , they are printed at the same time i.e. when the last data is received. How can I print them as soon as they are received? Must I use websockets ? 回答1: Use streaming json library like http://oboejs.com/ Oboe.js is an open source Javascript library for loading JSON using streaming,