-
Notifications
You must be signed in to change notification settings - Fork 177
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
[BREAKING]: Change internal layers stack to be value-based instead of type-based #789
Merged
Merged
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
2f17156
Change internal layers stack to be value-based instead of type-based
quinnj 747f725
more work for value-based stack
quinnj ee3aec8
fix tests
quinnj ad7c1a7
Fix 32-bit by ensuring consistent order of layers
quinnj 65188ed
more work
quinnj 3e7677b
move stuff around
quinnj 206b847
more iterating/ideas around revamping the client request stack/stacki…
quinnj ede2391
work
quinnj 4e9b8fe
more work
quinnj 60d4d73
Another refactor to move layers to a more functional architecture and
quinnj a9473b4
more cleanup
quinnj acc0727
fix failing tests
quinnj a0e904c
add global stack state w/ modifiers
quinnj 9aebfea
a little more cleanup
quinnj 131e7e5
Update test/loopback.jl
quinnj 08e8a6c
Update test/cookies.jl
quinnj a317e43
Update test/client.jl
quinnj 45e5a5a
Update test/chunking.jl
quinnj 3ea2c8b
Update src/DefaultHeadersRequest.jl
quinnj File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,27 @@ | ||
module BasicAuthRequest | ||
|
||
using ..Base64 | ||
|
||
import ..Layer, ..request | ||
using URIs | ||
using ..Pairs: getkv, setkv | ||
import ..Messages: setheader, hasheader | ||
import ..@debug, ..DEBUG_LEVEL | ||
|
||
export basicauthlayer | ||
""" | ||
request(BasicAuthLayer, method, ::URI, headers, body) -> HTTP.Response | ||
basicauthlayer(req) -> HTTP.Response | ||
|
||
Add `Authorization: Basic` header using credentials from url userinfo. | ||
""" | ||
abstract type BasicAuthLayer{Next <: Layer} <: Layer{Next} end | ||
export BasicAuthLayer | ||
|
||
function request(::Type{BasicAuthLayer{Next}}, | ||
method::String, url::URI, headers, body; kw...) where Next | ||
|
||
userinfo = unescapeuri(url.userinfo) | ||
|
||
if !isempty(userinfo) && getkv(headers, "Authorization", "") == "" | ||
@debug 1 "Adding Authorization: Basic header." | ||
setkv(headers, "Authorization", "Basic $(base64encode(userinfo))") | ||
function basicauthlayer(handler) | ||
return function(req; basicauth::Bool=true, kw...) | ||
if basicauth | ||
userinfo = unescapeuri(req.url.userinfo) | ||
if !isempty(userinfo) && !hasheader(req.headers, "Authorization") | ||
@debug 1 "Adding Authorization: Basic header." | ||
setheader(req.headers, "Authorization" => "Basic $(base64encode(userinfo))") | ||
end | ||
end | ||
return handler(req; kw...) | ||
end | ||
|
||
return request(Next, method, url, headers, body; kw...) | ||
end | ||
|
||
|
||
end # module BasicAuthRequest |
This file contains 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
Oops, something went wrong.
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.
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.
What does the stack traces look like now when everything are anonymous functions?
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.
also would it improve stacktraces if these were named functions?
e.g.
so they have names like
(::var"#basicauthhandler#5") (generic function with 1 method)
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.
I think the backtraces are as legible as they used to be: the use of closures means we still see a nested list of the layers, and the use of a module per layer means its pretty clear where the layer is coming from.