diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-11-10 23:56:57 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-11-11 00:04:39 +0100 |
| commit | 5d47b2d12caba33793a078d2eafae6ae3d2ad921 (patch) | |
| tree | 6928e070b939a37a4bf5af6ff7222e87f00ccae9 /include | |
| parent | b8cd00d00fa4dd2c45615c6b0367e3b57e12e98d (diff) | |
Implement HTTP byte serving
This commit allows the HTTP server to return partial content to clients,
rather than returning the whole resource. This can be particularly
useful for applications such as audio/video playback or showing large
PDF files.
Notes:
- Applications must not care about partial contents i.e., if a valid
user request was made, applications must still return HTTP status 200
("OK"), as usual. The HTTP server will then translate the status code to
206 ("Partial Content") if required.
Diffstat (limited to 'include')
| -rw-r--r-- | include/libweb/http.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/libweb/http.h b/include/libweb/http.h index 4e80570..736a561 100644 --- a/include/libweb/http.h +++ b/include/libweb/http.h @@ -49,6 +49,21 @@ struct http_payload { const char *tmpname; } put; + + struct http_get + { + struct http_get_range + { + enum + { + HTTP_GET_RANGE_NONE, + HTTP_GET_RANGE_START = 1 << 0, + HTTP_GET_RANGE_END = 1 << 1 + } state; + + unsigned long long start, end; + } range; + } get; } u; const struct http_arg @@ -64,6 +79,7 @@ struct http_payload #define HTTP_STATUSES \ X(CONTINUE, "Continue", 100) \ X(OK, "OK", 200) \ + X(PARTIAL_CONTENT, "Partial Content", 206) \ X(SEE_OTHER, "See other", 303) \ X(BAD_REQUEST, "Bad Request", 400) \ X(UNAUTHORIZED, "Unauthorized", 401) \ |
