Why does S3 sometimes return HTTP 206 when the whole file has been downloaded? - amazon-s3

I've had my S3 bucket logging into another bucket using Server Access Log Format for a while. For the Operation: REST.GET.OBJECT sometimes an HTTP Status: 206 Partial Content is returned because the whole file wasn't downloaded. But I can see in the logs that sometimes when HTTP Status: 206 is returned the whole file was downloaded. I've removed some fields to make it simpler:
Operation: REST.GET.OBJECT
Request-URI: "GET [File] HTTP/1.1"
HTTP Status: 206
Error Code: -
Bytes Sent: 76431360
Object Size: 76431360
Total Time: 16276
Turn-Around Time: 190
What happened here? If the Bytes Sent are the same as the Object Size then how can the source report this as a Partial Content?

The 206 status has nothing to do with incomplete file transfer. The server determines what status code to send before it starts sending the response body, so it would have to predict future to know whether it will be able to send the whole file.
Instead, what 206 status code actually means is that the following three things happened at once:
the client sent Range header in its request;
the server decided to honour it and send exactly the bytes requested, not the whole file;
the server was actually able to do so — the range was valid and satisfiable.
In this case, the standard requires the server to reply with the 206 status code, not 200, regardless whether the range happen to cover exactly the whole file or only a part of it.

Related

No response is received with ajaxForm when it processes a heavy task on the server

My application(Javascript + html) posts a CSV file with ajaxForm and does something on the server side, then the server returns a json data which indicates whether it succeeds or not.
When the CSV file is small, the server processed it within a few minutes. In this case, the browser returns a response as expected; however, if the CSV file is large and it takes 5 or 6 seconds to process it. In this case, the application does not receive anything.
I checked the message on the console, but couldn't see anything wrong.
I set the timeout to 0 as follows:
48 var options5 = {
49 dataType: 'json',
50 success: processRegister,
51 error: processError,
52 timeout: 0
53 };
54 $('#form_user_register').ajaxForm(options5);
Could someone please give me some advice to tackle this issue?
Also, what is the best way to handle a request which would take a long time (but want to inform its result to a client side)?

Node AWS.S3 SDK upload timeout

Using the Node AWS SDK S3.upload method is not completing multi part uploads for some reason.
A readable stream that receives uploads from a browser is set as the Body (the readable stream is able to be be piped to file writableStream without any problems).
S3.upload is given the following options object:
{
partSize: 1024*1024*5,
queueSize: 1
}
When trying to upload a ~8.5mb file, the file is completely sent from the browser, but the request returned from S3.upload continually fires 'httpUploadProgress' events that indicate that all bytes have been uploaded. The following is received continually until the error occurs:
progress { loaded: 8832825,
total: 8832825,
part: 1,
key: 'c82d3ef1-5d95-47df-aaa9-2cee48afd702' }
progress { loaded: 8832825,
total: 8832825,
part: 1,
key: 'c82d3ef1-5d95-47df-aaa9-2cee48afd702' }
progress { loaded: 8832825,
total: 8832825,
part: 1,
key: 'c82d3ef1-5d95-47df-aaa9-2cee48afd702' }
RequestTimeout: Your socket connection to the server was not read from
or written to within the timeout period. Idle connections will be
closed.
The progress loaded field shows that it has loaded the total bytes, but the upload is never completed. Even the end event on the readable stream fires.
Console logging in the SDK itself shows that S3.upload consumes all the available data from the readable stream even if the part size is set to 5mb and the queue size is set to 1.
Does the part size and queue size have an impact on proper usage of S3.upload? How can this problem be investigated further?
I had to use createMultipartUpload and uploadPart for my larger (8Mb) file upload.
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#uploadPart-property

Splunk rex query does not return desired result

I am looking to search for error type in my spunk. A typical error log looks like this:
ERROR 2016/03/16 22:13:55 Program exited with error Calling service: Post http://hostname/v1.21/resource/create?name=/60b80cf9-ebc4-11e5-a9cb-3c4a92db9491-2: read unix #->/var/run/program.sock: use of closed network connection (Client.Timeout exceeded while awaiting headers)
Note that common part is "Program exited with error". I am looking to capture the part that follows this common part of the error message. I tried with a couple of rex expressions. Both returned different results. Importantly, neither captured the error type I have shown above. I am giving the one that worked better here.
* | rex "Program exited with error\s+(?<reason>.+)" | top reason
An example of the log it matched-
Unable to get program status, Get http://192.168.0.2:2774/program/v1/status: net/http: timeout awaiting response headers
However, it did not match log of the form-
initial ZK connection failed, stat /var/program/f47aae5c-ea42-11e5-8975-fc15b40f4cc4/srcheck/started: no such file or directory
Calling service: Post http://hostname/v1.21/resource/create?name=/60b80cf9-ebc4-11e5-a9cb-3c4a92db9491-2: read unix #->/var/run/program.sock: use of closed network connection (Client.Timeout exceeded while awaiting headers)
Could someone help me understand what's wrong with my rex expression and what the right one would be so I get all possible error types?
This recipe:
"ERROR.*Program exited with error.*:.*:.*:\s+(?<reason>.+)"
will yield:
use of closed network connection (Client.Timeout exceeded while awaiting headers)
I don't have enough sample data to know if this will hold up or not. For example, I'm counting on exactly 3 colons, to get me to the interesting part. Also I don't know if you care about other things like the hostname, the fact that it's a Post, etc.. But based on your sample of 1, this answer should do the trick.

206 Partial Request - Single-range request with overlapping bytes

I am implementing a module that supports 206 partial requests.
After reading RFC rfc2616, i noticed that when receiving a multi-range request, overlapping ranges such as: "a-b, a-d" are not allowed.
My question is:
What happens with single-range request and overlapping bytes?
Request #1: a-b
Request #2: a-d
Do I need to ignore bytes a-b in the second request?
OR
Do I need to overwrite the bytes?
Thanks
Overwrite the bytes.
Responses does not depend on any previous request semantically because HTTP is a stateless protocol.

FTP response codes

I am troubleshooting Microsoft's FTP server (IIS 6.0) at a client site. In the FTP log, there's a few response codes that I'd like to know the meaning of.
For instance, in the line:
12:01:15 10.4.152.122 [194326]created x.jpg 550 1450
I'd like to know the meaning of 1450. There's other ones as well, like 550 2, and 550 32.
Anyone know of a site or reference that has the meaning of these sub-codes (not sure what the correct term is)?
The 450 / 550 values are both from RFC 959.
As 450 and 550 are both FTP errors, the second values might correspond to Windows error codes. The page here is consistent with that, with values 2, 32, and 1450 all relating to file I/O errors.
2 = ERROR_FILE_NOT_FOUND
The system cannot find the file specified.
32 = ERROR_SHARING_VIOLATION
The process cannot access the file because it is being used by another
process.
1450 = ERROR_NO_SYSTEM_RESOURCES
- Insufficient system resources exist to complete the requested
service.
According to this, 550 is:
Requested action not taken.
File unavailable (e.g., file not found, no access).