studio-b12 / gowebdav

A golang WebDAV client library and command line tool.
BSD 3-Clause "New" or "Revised" License
309 stars 89 forks source link

Support range bytes request #23

Closed ochanism closed 2 years ago

ochanism commented 6 years ago

I tried to call ReadStream with header SetHeader("Range", "bytes=10-100"), but it failed because ReadStream only accepts 200 http response code. The response code of range bytes request is 206 (Partial Content).

https://github.com/studio-b12/gowebdav/blob/3cd755d6c4753083fdfcd45b71e88100bf8f2057/client.go#L332

I think the above code needs to be revised as follows: if rs.StatusCode == 200 || rs.StatusCode == 206 {

MrVine commented 6 years ago

I think that it is reasonably @chripo , what do you think?

chripo commented 6 years ago

i like the idea, it's a great feature. but it need's more work, because the Range header should be applied to the specific request not generally (what SetHeader does).

a way to go... the c.req func supports an intercept function as argument which could be used to set the Range header for a specific call. wrapped in a new ReadStreamRange or ReadSteamChunk func would provide the functionality.

patches and improvements always welcome.