Skip to content

HTTP error handling customization#492

Open
mmatczuk wants to merge 4 commits intoelazarl:masterfrom
mmatczuk:http_error_handling
Open

HTTP error handling customization#492
mmatczuk wants to merge 4 commits intoelazarl:masterfrom
mmatczuk:http_error_handling

Conversation

@mmatczuk
Copy link
Copy Markdown
Contributor

@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 mmatczuk force-pushed the http_error_handling branch from b7a3b82 to 5692818 Compare November 9, 2022 09:56
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