mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-12-11 09:58:49 +00:00
feat: enhance anonProxyHandler to handle binary data safely
- Added Base64 encoding for the response body in the anonProxyHandler to prevent corruption of binary data when returned in JSON format. - Updated the response structure to include the encoded body, ensuring compatibility with various data types.
This commit is contained in:
parent
fe16d503b5
commit
351ce086bf
16
CHANGELOG.md
16
CHANGELOG.md
@ -10,6 +10,18 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant
|
||||
|
||||
### Changed
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Fixed
|
||||
|
||||
## [0.52.15]
|
||||
|
||||
### Added
|
||||
|
||||
- Added Base64 encoding for the response body in the anonProxyHandler to prevent corruption of binary data when returned in JSON format.
|
||||
|
||||
### Changed
|
||||
|
||||
- **GoReleaser**: Updated to build only `network-cli` binary (v0.52.2+)
|
||||
- Other binaries (node, gateway, identity) now installed via `network-cli setup`
|
||||
- Cleaner, smaller release packages
|
||||
@ -125,7 +137,7 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant
|
||||
|
||||
### Fixed
|
||||
|
||||
- Regular nodes rqlite not starting
|
||||
- Regular nodes rqlite not starting
|
||||
|
||||
## [0.51.2] - 2025-09-26
|
||||
|
||||
@ -155,7 +167,6 @@ The format is based on [Keep a Changelog][keepachangelog] and adheres to [Semant
|
||||
|
||||
### Fixed
|
||||
|
||||
|
||||
## [0.50.0] - 2025-09-23
|
||||
|
||||
### Added
|
||||
@ -286,4 +297,3 @@ _Initial release._
|
||||
|
||||
[keepachangelog]: https://keepachangelog.com/en/1.1.0/
|
||||
[semver]: https://semver.org/spec/v2.0.0.html
|
||||
|
||||
|
||||
2
Makefile
2
Makefile
@ -21,7 +21,7 @@ test-e2e:
|
||||
|
||||
.PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports
|
||||
|
||||
VERSION := 0.52.14
|
||||
VERSION := 0.52.15
|
||||
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
@ -176,11 +177,15 @@ func (g *Gateway) anonProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||
zap.Int("bytes", len(respBody)),
|
||||
zap.Duration("duration", duration))
|
||||
|
||||
// Base64-encode the body to safely handle binary data in JSON
|
||||
// This prevents corruption when binary data is converted to a string
|
||||
bodyBase64 := base64.StdEncoding.EncodeToString(respBody)
|
||||
|
||||
// Return the proxied response
|
||||
writeJSON(w, http.StatusOK, anonProxyResponse{
|
||||
StatusCode: resp.StatusCode,
|
||||
Headers: respHeaders,
|
||||
Body: string(respBody),
|
||||
Body: bodyBase64,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user