Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP error handling customization #492

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mmatczuk
Copy link

@mmatczuk mmatczuk commented Nov 9, 2022

This PR unifies HTTP and HTTPS error handling and makes it customizable by adding Proxy.HTTPErrorHandler.

  • HTTP code is moved to http.go file
  • HTTP code calls httpError if response in nil
  • httpError uses Proxy.HTTPErrorHandler if specified

Fixes #51

This is for parity with HTTPS and the handleHttps function.
This is for parity with HTTPS and the handleHttps function.
If response is nil call httpError like in https code.
@mmatczuk mmatczuk changed the title Http error handling HTTP error handling customization Nov 9, 2022
The idea is taken from the Stripe fork [1] but instead of context it's set globally for proxy.
It gives much flexibility to error handling.

[1] https://github.com/stripe/goproxy/blob/3f1dfba6d1a4747c78fee7069e2f28fd6b703917/ctx.go#L21
mmatczuk added a commit to saucelabs/forwarder that referenced this pull request Nov 9, 2022
My fork is hosting patches I sent upstream to fix issues.

It contains patches from
* elazarl/goproxy#488
* elazarl/goproxy#492
mmatczuk added a commit to saucelabs/forwarder that referenced this pull request Nov 9, 2022
My fork is hosting patches I sent upstream to fix issues.

It contains patches from
* elazarl/goproxy#488
* elazarl/goproxy#492
mmatczuk added a commit to saucelabs/forwarder that referenced this pull request Nov 10, 2022
My fork is hosting patches I sent upstream to fix issues.

It contains patches from
* elazarl/goproxy#488
* elazarl/goproxy#492
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Status code on unresolvable hosts.
1 participant