-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP 1.0 range support? #18
Comments
Apart from fixing issue #18, this changes a few comments
I've fixed the flag, I'm not sure what you have written at the end though. |
There are 2 flags related to HTTPC_OPT_HTTP_1_0, so one more still needs to be changed case FLD_ACCEPT_RANGES:
if (httpc_case_insensitive_search(line, "bytes")) {
h->accept_ranges = !!(h->os->flags & HTTPC_OPT_HTTP_1_0); // it should be negated once
return info(h, "Accept-Ranges: bytes");
} With that change if error occurs during HTTP 1.1 GET request, httpc.c will try to retry transfer from last successful position. It will add I reproduced the issue. Below are logs from debug session that visualize that problem:
I tried to do something like that and it worked fine for me. But I don't know if it could be useful also for other cases. case FLD_CONTENT_LENGTH:
if (h->length_set == 0){
if (httpc_scan_number(&line[fld->length], &h->length, 10) < 0)
return error(h, "invalid content length: %s", line);
h->length_set = 1;
return info(h, "Content Length: %lu", (unsigned long)h->length);
}
return info(h, "Content Length remains from previous request: %lu", (unsigned long)h->length); and also needed to remove these (they probably could be in initial step before open): static int httpc_parse_response_header(httpc_t *h, httpc_buffer_t *b0) {
h->v1 = 0;
h->v2 = 0;
os->response = 0;
- h->length = 0; <-- remove
h->identity = 1;
- h->length_set = 0; <-- remove
h->keep_alive = !(os->flags & HTTPC_OPT_HTTP_1_0);
h->accept_ranges = !(os->flags & HTTPC_OPT_HTTP_1_0);
b0->used = 0; and lastly... if server respond with |
Right you are about the second flag, I've pushed a fix for that. Thanks for writing up a detailed report, I think you are right, but it will take more time for me to analyze this which I do not have at the moment. I'll get around to looking at this properly sometime, I'd prefer not to make changes that could potentially break anything else. I'd keep a local/personal of the other changes you've made. I'm not planning on making massive changes to this library any time soon so any personal branch would not go stale. |
The code provides a
Range
header only to HTTP 1.0 and not for HTTP 1.1. Is that for sure correct? Shouldn't be that reversed?Also using modified at run time
Range
header during retrying previous transfer after network failure cause obtaining reducedContent-Length
and because of thatGET
request ends somewhere in middle of file. The first assign ofh->length
should persist from the firstContent-Length
response header, and shouldn't be modified during retrying. Do you agree?The text was updated successfully, but these errors were encountered: