|
From: Török E. <edw...@et...> - 2015-01-26 13:51:54
|
Hi, set_content_range in nethttp.ml sets header of the form "Content-Range: 598-3135/3136", but it should set "Content-Range: bytes 598-3135/3136", see http://tools.ietf.org/html/rfc7233#section-4.2 Interestingly the headers set by Nethttp.set_content_range worked fine with clients like curl/wget or even browsers. Then I tried using my server as an APT http repository and it complained: HTTP/1.1 206 Partial Content Accept-Ranges: bytes Content-Length: 2538 Content-Range: 598-3135/3136 Content-Type: binary/octet-stream Date: Sun, 25 Jan 2015 09:51:26 GMT ETag: "2015-01-23 10:19:24.611:0ad6cf8d3cfc5ebfc5983d6e8c626bc8" Last-Modified: Fri, 23 Jan 2015 10:19:24 GMT Server: libres3-0.9.beta-68-g137d4f1-dirty x-amz-id-2: dm9sLXJlcG8AL2RlYmlhbi9kaXN0cy93aGVlenkvSW5SZWxlYXNlADE0MjIxNzk0ODYuNDE= x-amz-request-id: libres3_d598fe779a57c81f28f25e1dd9802276_14711_1209_1422179483.37 400 URI Failure URI: [...] Message: The HTTP server sent an invalid Content-Range header Testcase (make sure Nethttp can parse the header it generates): $ cat >x.ml <<EOF #use "topfind" #require "netstring" let test_bytes b = let h = new Netmime.basic_mime_header [] in Nethttp.Header.set_content_range h b; let cr = h#field "Content-Range" in (* if String.length cr < 6 || String.sub cr 0 6 <> "bytes" then h#update_field "Content-Range" ("bytes " ^ cr); let cr = h#field "Content-Range" in*) prerr_endline cr; assert (Nethttp.Header.get_content_range h = b) let () = test_bytes (`Bytes ((Some (42L, 1233L), Some 1234L))); test_bytes (`Bytes ((Some (42L, 1233L), None))); test_bytes (`Bytes (None, Some 1234L)); EOF $ ocaml x.ml 42-1233/1234 Exception: Nethttp.Bad_header_field "Nethttp.get_content_range". Best regards, --Edwin |