Repository navigation
feat: log binary and compressed bodies instead of dropping the whole entry - #4
Merged
Merged
Conversation
…0 s for open connections, then writes all queued log entries before exiting. A second signal skips the wait.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
vscodelogger failed on response bodies that are not UTF-8 text (PNG, GeoTIFF, …) and on unsupportedContent-Encodings. The response was still forwarded, but the whole log entry was dropped, including request line, status and headers. A log of an OGC API Tiles compliance run therefore contained only the JSON error responses.Changes
# Body: image/tiff; application=geotiff, 131072 bytes, sha256 3f1c…Content-Type(RFC 9110 §8.3), ignoring case and parameters. Text meanstext/*,application/json,application/xml,application/x-www-form-urlencoded,application/javascript, and the+jsonand+xmlsuffixes. Without aContent-Type, valid UTF-8 counts as text.charset(viaencoding_rs), defaulting to UTF-8. If decoding fails, the placeholder is used.Content-Encodingis removed on the logged copy only. Supported:gzip/x-gzip,deflate(zlib or raw),br,zstd, including stacked codings. Unknown codings are logged as binary. Decompressed output is capped at 64 MiB. The client still receives the original bytes.HEAD,1xx,204and304responses (RFC 9110 §6.4.1).--max-logged-body-bytes/MAX_LOGGED_BODY_BYTES: truncates text bodies on a char boundary and notes how many bytes were cut.--binary-body-dir/BINARY_BODY_DIR: stores binary bodies as<sha256>.<ext>, so identical bodies are stored once.< ./bodies/<file>, so the logged request can be sent again from VS Code or JetBrains.# File: ./bodies/<file>comment.#lines inside a body as content.examples/demo.shandexamples/demo_upstream.rs. The script runs the proxy in front of a test server that covers all of the above and writestarget/demo/requests.http.netfeature is now declared explicitly. It used to be enabled throughhyper-util< 0.1.21.New dependencies:
sha2,encoding_rs,brotli,ruzstd(pure Rust, no C toolchain needed).How to test
cargo test examples/demo.sh