Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/itrooz/ensure-content-length
Small proxying web server to ensure Content-Length header is always present in HTTP responses
https://github.com/itrooz/ensure-content-length
go golang
Last synced: about 2 months ago
JSON representation
Small proxying web server to ensure Content-Length header is always present in HTTP responses
- Host: GitHub
- URL: https://github.com/itrooz/ensure-content-length
- Owner: iTrooz
- Created: 2024-08-10T02:02:54.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-08-10T02:06:51.000Z (6 months ago)
- Last Synced: 2024-10-20T21:05:49.829Z (3 months ago)
- Topics: go, golang
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ensure-Content-Length
This webserver will proxy requests add ensure a content-length response header is set, by loading the response body in RAM to calculate its length when there is no such header.
Content-Length may not be set in a number of cases, including in most web servers when a content encoding is set (See https://serverfault.com/questions/529621/force-nginx-to-send-content-length-header-for-static-files-with-gzip and https://serverfault.com/questions/183843/content-length-not-sent-when-gzip-compression-enabled-in-apache)
# How to run
Build:
`go build -o ensure-content-length`Run:
`./ensure-content-length 8080 https://example.com`This will make our proxy webserver run on port 8080, and proxy its requests to https://example.com. For example, http://localhost:8080/my/file will become https://example.com/my/file
# Notes
According to https://stackoverflow.com/questions/3819280/content-length-when-using-http-compression, `Content-Length` is the length of the *compressed* content.