Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/functions: make snippets func more robust
Use the context from incoming requests to do outgoing requests. This way, if a client gives up or disconnects, we give up too. Refuse any incoming request that isn't a GET or a POST. Set up the outgoing POST request body when building the request. Setting http.Request.Body directly after the constructor seems OK, but the constructor also performs some of its documented logic. Defer closing the incoming body; the net/http docs say we should. It's unclear what happens if we don't, and it seemed to mostly work, but there's no reason to go against the documentation. In the success case, don't simply copy the body over; also copy over the response status code. Otherwise, if the server responds with a 403 or 500 and no body, we might give the client a 200 with no body. Signed-off-by: Daniel Martí <[email protected]> Change-Id: Ia9a9633c34d9dd6d81de6e747aca36bbe9c48bdf Reviewed-on: https://review.gerrithub.io/c/cue-lang/cuelang.org/+/1171059 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Paul Jolly <[email protected]> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cuelang.org/+/1171222
- Loading branch information