Skip to content
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

range header does not work per spec #21

Open
jmgurney opened this issue Oct 9, 2020 · 1 comment
Open

range header does not work per spec #21

jmgurney opened this issue Oct 9, 2020 · 1 comment

Comments

@jmgurney
Copy link

jmgurney commented Oct 9, 2020

I needed a test WebDAV server, so I decided to attempt to use the package, but it appears that this software does not implement the range header properly. The RFC https://tools.ietf.org/html/rfc2616#section-14.35 states that the ranges is inclusive:

The last-byte-pos value gives the
   byte-offset of the last byte in the range; that is, the byte
   positions specified are inclusive. Byte offsets start at zero.

In the request, this does not appear to be the case. This is a log from a request:

>>> GET /somefile HTTP/1.1
>>> Host: 127.0.0.1:5555
>>> Accept: */*
>>> User-Agent: test libfetch/2.0
>>> Range: bytes=2-21
>>> Connection: close
>>> 
<<< HTTP/1.0 206 Partial Content
<<< Server: DAV/0.9.14 Python/3.7.7
<<< Date: Fri, 09 Oct 2020 21:46:08 GMT
<<< Content-type: application/octet-stream
<<< Transfer-Encoding: chunked
<<< Date: Fri, 09 Oct 2020 21:46:08 GMT
<<< DAV: 1,2
<<< Last-Modified: Fri, 09 Oct 2020 21:43:02 GMT
<<< Keep-Alive: timeout=15, max=86
last modified: [2020-10-09 21:43:02]
<<< Connection: Keep-Alive
<<< Content-Length: 19
<<< Content-Type: application/octet-stream
content length: [19]
<<< 
offset 0, length -1, size -1, clength 19

The request requests 20 bytes, (21 - 2 + 1), but as you can see, the reply only includes 19 bytes.

It also looks like it does not honor range, as if I manually do the request:

 $ telnet 0 5555
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.
GET /somefile HTTP/1.1
Host: 127.0.0.1:5555
Accept: */*
User-Agent: test libfetch/2.0
Range: bytes=2-21
Connection: close

HTTP/1.0 206 Partial Content
Server: DAV/0.9.14 Python/3.7.7
Date: Fri, 09 Oct 2020 21:51:20 GMT
Content-type: application/octet-stream
Transfer-Encoding: chunked
Date: Fri, 09 Oct 2020 21:51:20 GMT
DAV: 1,2
Last-Modified: Fri, 09 Oct 2020 21:43:02 GMT
Keep-Alive: timeout=15, max=86
Connection: Keep-Alive
Content-Length: 19
Content-Type: application/octet-stream

1f400
is is a test to give some bogus data at first

1f400

1f400

1f400

1f400

1f400

1f400

1f400

5ffe

0

^]
telnet> quit
Connection closed.

A lot more data is included than the specified range:

freebsd@generic:~/lf.test $ echo -n 'is is a test to give some bogus data at first' | wc
       0      11      45

The data was a simple file that contained the above string, and zero padded to 1MB.

@andrewleech
Copy link
Owner

Thanks for the testing and clear reporting. I'm not actively working on this project though, to be honest I only ever created it as a test tool for a WebDAV client I used to work on.

I'm more than happy to merge and release any patches though if you're interested in fixing the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants