-
Notifications
You must be signed in to change notification settings - Fork 170
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
Threescale 7967 http proxy patch #1323
Changes from all commits
2fc0df2
1fa7dd8
d9b6f30
dc752e9
4b47c81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ local function connect_direct(httpc, request) | |
local uri = request.uri | ||
local host = uri.host | ||
local ip, port = httpc:resolve(host, nil, uri) | ||
|
||
-- #TODO: This logic may no longer be needed as of PR#1323 and should be reviewed as part of a refactor | ||
local options = { pool = format('%s:%s', host, port) } | ||
local ok, err = httpc:connect(ip, port or default_port(uri), options) | ||
|
||
|
@@ -72,8 +72,9 @@ local function _connect_proxy_https(httpc, request, host, port) | |
end | ||
|
||
local function connect_proxy(httpc, request, skip_https_connect) | ||
-- target server requires hostname not IP and DNS resolution is left to the proxy itself as specified in the RFC #7231 | ||
-- https://httpwg.org/specs/rfc7231.html#CONNECT | ||
local uri = request.uri | ||
local host, port = httpc:resolve(uri.host, uri.port, uri) | ||
local proxy_uri = request.proxy | ||
|
||
if proxy_uri.scheme ~= 'http' then | ||
|
@@ -94,15 +95,17 @@ local function connect_proxy(httpc, request, skip_https_connect) | |
ngx.log(ngx.DEBUG, 'connection to ', proxy_uri.host, ':', proxy_uri.port, ' established', | ||
', pool: ', options.pool, ' reused times: ', httpc:get_reused_times()) | ||
|
||
ngx.log(ngx.DEBUG, 'targeting server ', uri.host, ':', uri.port) | ||
|
||
if uri.scheme == 'http' then | ||
-- http proxy needs absolute URL as the request path | ||
request.path = format('%s://%s:%s%s', uri.scheme, host, port, uri.path or '/') | ||
request.path = format('%s://%s:%s%s', uri.scheme, uri.host, uri.port, uri.path or '/') | ||
return httpc | ||
elseif uri.scheme == 'https' and skip_https_connect then | ||
request.path = format('%s://%s:%s%s', uri.scheme, host, port, request.path or '/') | ||
return _connect_tls_direct(httpc, request, host, port) | ||
request.path = format('%s://%s:%s%s', uri.scheme, uri.host, uri.port, request.path or '/') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that this will work, but please test this with routing policy, I remember that we had issues with that. Also, with Camel policy There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will check with the routing policy yep! However, the camel policy I might need to get some help with because I don't understand how that works and the tests for that specific policy are not passing even without my changes. It seems like something is broken there or maybe it's expected and we need to test in another way? |
||
return _connect_tls_direct(httpc, request, uri.host, uri.port) | ||
elseif uri.scheme == 'https' then | ||
return _connect_proxy_https(httpc, request, host, port) | ||
return _connect_proxy_https(httpc, request, uri.host, uri.port) | ||
|
||
else | ||
return nil, 'invalid scheme' | ||
|
@@ -176,4 +179,4 @@ end | |
|
||
_M.new = connect | ||
|
||
return _M:reset() | ||
return _M:reset() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
were all these newlines and formatting changes in the CHANGELOG meant to be committed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no I didn't make those changes, not sure where they came from to be honest. I only added a CHANGELOG entry, I assume you are referring to the CHANGELOG and not README though right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I was :) - fixed my comment