Skip to content

range header does not work per spec #21

@jmgurney

Description

@jmgurney

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions