PrivateBin/lib
Zwyx 6130547ca6
Add response header X-Uncompressed-Content-Length for JSON API
Because the response from the API is PHP output, the usual `Content-Length` header is absent.

This [custom header technique](https://stackoverflow.com/questions/15097712/how-can-i-use-deflated-gzipped-content-with-an-xhr-onprogress-function/32799706#32799706) allows the client to know the total length of the data being received, in order to display a progress indicator.

Here's a code example with `XMLHttpRequest`:


```
xhr.addEventListener("progress", (e) => {
	if (e.lengthComputable) {
		onDownloadProgress({
			loaded: e.loaded,
			total: e.total,
		});
	} else {
		const uncompressedContentLength = xhr.getResponseHeader(
			"X-Uncompressed-Content-Length",
		);

		if (uncompressedContentLength) {
			onDownloadProgress({
				loaded: e.loaded,
				total: Number(uncompressedContentLength),
			});
		}
	}
});
```

Notes:
- `Fetch` can be used as well (only reason I use `XMLHttpRequest` is because `fetch` doesn't allow to track the progress of uploaded data (when creating a paste); whereas `XMLHttpRequest` does).
- `e.loaded` can be different between browsers; Firefox reports the length of the compressed data, Chrome reports the length of uncompressed data (see https://github.com/whatwg/xhr/issues/388). A workaround for this is to manually set our progress indicator to 100% when the request finishes.
2024-03-24 19:40:50 +08:00
..
Data phpdoc improvements, fixes #1036 2024-03-10 17:07:10 +01:00
Model incrementing version 2024-02-11 15:31:11 +01:00
Persistence incrementing version 2024-02-11 15:31:11 +01:00
.htaccess updating shipped .htaccess files for Apache 2.4 as per https://httpd.apache.org/docs/2.4/upgrading.html#access - Thanks @EchoDev, fixes #194 2017-03-11 08:56:14 +01:00
Configuration.php incrementing version 2024-02-11 15:31:11 +01:00
Controller.php Add response header X-Uncompressed-Content-Length for JSON API 2024-03-24 19:40:50 +08:00
Filter.php incrementing version 2024-02-11 15:31:11 +01:00
FormatV2.php incrementing version 2024-02-11 15:31:11 +01:00
I18n.php phpdoc improvements 2024-03-10 18:01:46 +01:00
Json.php incrementing version 2024-02-11 15:31:11 +01:00
Model.php incrementing version 2024-02-11 15:31:11 +01:00
Request.php Allow for shortenviayourls in query params 2024-03-16 16:55:49 -04:00
View.php incrementing version 2024-02-11 15:31:11 +01:00
Vizhash16x16.php incrementing version 2024-02-11 15:31:11 +01:00
YourlsProxy.php incrementing version 2024-02-11 15:31:11 +01:00