Skip to content

Instantly share code, notes, and snippets.

@vayam
Last active December 17, 2015 12:59
Show Gist options
  • Save vayam/5614199 to your computer and use it in GitHub Desktop.
Save vayam/5614199 to your computer and use it in GitHub Desktop.
TUS GET/HEAD Flow with Entity-Receive Header

Upload Client

HEAD /files/24e533e02ec3bc40c387f1a0e460e216 HTTP/1.1
Host: tus.example.org
Entity-Receive: available

Response:

HTTP/1.1 200 Ok
Content-Length: 70

For clients interested in downloading whatever is available:

GET /files/24e533e02ec3bc40c387f1a0e460e216 HTTP/1.1
Host: tus.example.org
Entity-Receive: available

Response:

HTTP/1.1 200 Ok
Content-Length: 70

bytes

Download client (Standard HTTP client - browser/curl)

waits until the file is downloaded

HEAD /files/24e533e02ec3bc40c387f1a0e460e216 HTTP/1.1
Host: tus.example.org

Response:

HTTP/1.1 200 Ok
Content-Length: 100


GET /files/24e533e02ec3bc40c387f1a0e460e216 HTTP/1.1
Host: tus.example.org

Response:

HTTP/1.1 200 Ok
Content-Length: 100

bytes

Advanced Downloader

HEAD /files/24e533e02ec3bc40c387f1a0e460e216 HTTP/1.1
Host: tus.example.org


Response
HTTP/1.1 200 Ok
Accept-Ranges: bytes
Content-Length: 100


GET /files/24e533e02ec3bc40c387f1a0e460e216 HTTP/1.1
Host: tus.example.org
Range: bytes=0-

Response:

HTTP/1.1 206 Partial Content
Accept-Ranges: bytes
Content-Length: 100
Content-Range: bytes 0-99/100

bytes

>> Connection dropped after receiving 70 bytes



GET /files/24e533e02ec3bc40c387f1a0e460e216 HTTP/1.1
Host: tus.example.org
Range: bytes=70-

Response:

HTTP/1.1 206 Partial Content
Accept-Ranges: bytes
Content-Length: 100
Content-Range: bytes 70-99/100

bytes


Advanced Downloader to receive available bytes

HEAD /files/24e533e02ec3bc40c387f1a0e460e216 HTTP/1.1
Host: tus.example.org
Entity-Receive: available


Response:

HTTP/1.1 200 Ok
Accept-Ranges: bytes
Content-Length: 70

GET /files/24e533e02ec3bc40c387f1a0e460e216 HTTP/1.1
Host: tus.example.org
Entity-Receive: available
Range bytes=0- 

Response:

HTTP/1.1 200 Ok
Content-Range: bytes 0-70/70
Content-Length: 70

bytes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment