ProxyClient | Golang proxy library , API consistent | Proxy library
kandi X-RAY | ProxyClient Summary
kandi X-RAY | ProxyClient Summary
Golang proxy library, API consistent with net. Support socks4, socks4a, socks5, http, https and other proxy protocols.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ProxyClient
ProxyClient Key Features
ProxyClient Examples and Code Snippets
Community Discussions
Trending Discussions on ProxyClient
QUESTION
I have a controller proxy api endpoint where it receives different request payloads which are intended to different services. This controller validates payload and adds few headers based on certain rules. In this current context, i do not want to parse the received response from upstream services. proxy method should simply stream response to downstream clients so that it can scale well without going into any memory issues when dealing with large response payloads.
I have implemented method like this:
...ANSWER
Answered 2021-Feb-04 at 12:45Your first code snippet fails with memory issues because it is buffering in memory the whole response body as a String
and forwards it after. If the response is quite large, you might fill the entire available memory.
The second approach also fails because instead of returning the entire Flux
(so the entire response as buffers), you're only returning the first one. This fails because the response is incomplete.
Even if you manage to fix this particular issue, there are many other things to pay attention to:
- it seems you're not returning the original response headers, effectively changing the response content type
- you should not forward all the incoming response headers, as some of them are really up to the server (like transfer encoding)
- what happens with security-related request/response headers?
- how are you handling tracing and metrics?
You could take a look at the Spring Cloud Gateway project, which handles a lot of those subtleties and let you manipulate requests/responses.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ProxyClient
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page