proxy mode: operate on http responses rather than requests#29
Open
aidansteele wants to merge 3 commits intoiann0036:mainfrom
Open
proxy mode: operate on http responses rather than requests#29aidansteele wants to merge 3 commits intoiann0036:mainfrom
aidansteele wants to merge 3 commits intoiann0036:mainfrom
Conversation
aidansteele
commented
Apr 6, 2021
| uri := req.RequestURI | ||
|
|
||
| body, _ := ioutil.ReadAll(req.Body) | ||
| req.Body = ioutil.NopCloser(bytes.NewBuffer(body)) |
Author
There was a problem hiding this comment.
I moved the request body draining into this handleAWSRequest function to more closely match e.g. what httputil.DumpRequest does.
Owner
|
Looks like this isn't working based on my initial tests. Can you confirm whether it worked for you? |
Author
|
Nice catch. I missed that because my testing didn't involve POST bodies. I've since fixed that and added a basic E2E test to avoid regression. If you add some credentials to this repo, you could have a GitHub action to exercise these tests like: on: [push, pull_request]
name: CI
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.16
- name: test
run: go test -v ./...
env:
AWS_REGION: ap-southeast-2
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
aidansteele
commented
Apr 9, 2021
Comment on lines
+18
to
+22
| parseConfig() | ||
| flag.Parse() | ||
| loadMaps() | ||
| readServiceFiles() | ||
| *modeFlag = "proxy" |
Author
There was a problem hiding this comment.
This is pretty ugly, but I figured I didn't want to make bigger changes in a single PR
Open
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.
I moved the proxy mode logic into the response-handling function of goproxy, so that we have access to the response status code as per the TODO.
I also extracted the AWS hostname regexp to a global variable for a (probably irrelevant) speedup