Skip to content

Commit 5bc54e5

Browse files
committed
Merge #1
Merged by hand, many of these changes were already made.
1 parent ea97668 commit 5bc54e5

21 files changed

+97
-143
lines changed

src/AWS4AuthRequest.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module AWS4AuthRequest
22

3-
using Base64
4-
using Dates
5-
using Unicode
3+
using ..Base64
4+
using ..Dates
5+
using ..Unicode
66
using MbedTLS: digest, MD_SHA256, MD_MD5
77
import ..Layer, ..request, ..Headers
88
using ..URIs
@@ -27,10 +27,12 @@ export AWS4AuthLayer
2727
function request(::Type{AWS4AuthLayer{Next}},
2828
uri::URI, req, body; kw...) where Next
2929

30+
@static if VERSION > v"0.7.0-DEV.2915"
3031
if !haskey(kw, :aws_access_key_id) &&
3132
!haskey(ENV, "AWS_ACCESS_KEY_ID")
3233
kw = merge(dot_aws_credentials(), kw)
3334
end
35+
end
3436

3537
sign_aws4!(req.method, uri, req.headers, req.body; kw...)
3638

@@ -117,6 +119,7 @@ function sign_aws4!(method::String,
117119
))
118120
end
119121

122+
@static if VERSION > v"0.7.0-DEV.2915"
120123

121124
using IniFile
122125

@@ -148,5 +151,6 @@ function dot_aws_credentials()::NamedTuple
148151
aws_secret_access_key = String(get(ini, p, "aws_secret_access_key")))
149152
end
150153

154+
end
151155

152156
end # module AWS4AuthRequest

src/BasicAuthRequest.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module BasicAuthRequest
22

3-
if VERSION > v"0.7.0-DEV.2338"
4-
using Base64
5-
end
3+
using ..Base64
64

75
import ..Layer, ..request
86
using ..URIs

src/ConnectionPool.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ function Base.readavailable(t::Transaction)::ByteView
182182
end
183183

184184

185-
@static if VERSION < v"0.7.0-DEV.2915" const copyto! = copy! end
185+
186+
@static if !isdefined(Base, :copyto!)
187+
const copyto! = copy!
188+
end
186189

187190
function Base.readbytes!(t::Transaction, a::Vector{UInt8}, nb::Int)
188191

src/HTTP.jl

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import MbedTLS.SSLContext
66

77

88
const DEBUG_LEVEL = 0
9-
const minimal = false
109

1110
include("compat.jl")
1211
include("debug.jl")
@@ -15,18 +14,15 @@ include("Pairs.jl")
1514
include("Strings.jl")
1615
include("IOExtras.jl") ;import .IOExtras.IOError
1716
include("URIs.jl") ;using .URIs
18-
if !minimal
1917
include("consts.jl")
2018
include("utils.jl")
2119
include("fifobuffer.jl") ;using .FIFOBuffers
2220
include("cookies.jl") ;using .Cookies
2321
include("multipart.jl")
24-
end
2522
include("Parsers.jl") ;import .Parsers: Parser, Headers, Header,
2623
ParsingError, ByteView
2724
include("ConnectionPool.jl")
2825
include("Messages.jl") ;using .Messages
29-
import .Messages: header, hasheader
3026
include("Streams.jl") ;using .Streams
3127

3228

@@ -416,22 +412,16 @@ end))
416412
"""
417413

418414
abstract type Layer end
419-
if !minimal
420415
include("RedirectRequest.jl"); using .RedirectRequest
421416
include("BasicAuthRequest.jl"); using .BasicAuthRequest
422-
if VERSION > v"0.7.0-DEV.2338"
423417
include("AWS4AuthRequest.jl"); using .AWS4AuthRequest
424-
end
425418
include("CookieRequest.jl"); using .CookieRequest
426419
include("CanonicalizeRequest.jl"); using .CanonicalizeRequest
427420
include("TimeoutRequest.jl"); using .TimeoutRequest
428-
end
429421
include("MessageRequest.jl"); using .MessageRequest
430422
include("ExceptionRequest.jl"); using .ExceptionRequest
431423
import .ExceptionRequest.StatusError
432-
if !minimal
433424
include("RetryRequest.jl"); using .RetryRequest
434-
end
435425
include("ConnectionRequest.jl"); using .ConnectionRequest
436426
include("StreamRequest.jl"); using .StreamRequest
437427

@@ -555,9 +545,7 @@ function stack(;redirect=true,
555545
status_exception=true,
556546
readtimeout=0,
557547
kw...)
558-
if minimal
559-
MessageLayer{ExceptionLayer{ConnectionPoolLayer{StreamLayer}}}
560-
else
548+
561549
NoLayer = Union
562550

563551
(redirect ? RedirectLayer : NoLayer){
@@ -572,19 +560,16 @@ function stack(;redirect=true,
572560
(readtimeout > 0 ? TimeoutLayer : NoLayer){
573561
StreamLayer
574562
}}}}}}}}}}
575-
end
576563
end
577564

578565

579-
if !minimal
580-
if VERSION > v"0.7.0-DEV.2338"
581-
include("WebSockets.jl") ;using .WebSockets
582-
end
583566
include("client.jl")
584567
include("sniff.jl")
585-
include("Handlers.jl"); using .Handlers
586-
include("Servers.jl"); using .Servers.listen
587-
end
568+
include("Handlers.jl") ;using .Handlers
569+
include("Servers.jl") ;using .Servers.listen
570+
571+
include("WebSockets.jl") ;using .WebSockets
572+
588573
include("precompile.jl")
589574

590575
end # module

src/MessageRequest.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ using ..URIs
77
using ..Messages
88
import ..Messages.bodylength
99
using ..Headers
10-
using ..minimal
11-
if !minimal
1210
using ..Form
13-
end
1411

1512

1613
"""
@@ -50,9 +47,7 @@ end
5047
bodylength(body) = unknown_length
5148
bodylength(body::AbstractVector{UInt8}) = length(body)
5249
bodylength(body::AbstractString) = sizeof(body)
53-
if !minimal
5450
bodylength(body::Form) = length(body)
55-
end
5651
bodylength(body::Vector{T}) where T <: AbstractString = sum(sizeof, body)
5752
bodylength(body::Vector{T}) where T <: AbstractArray{UInt8,1} = sum(length, body)
5853
bodylength(body::IOBuffer) = nb_available(body)

src/Messages.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ export Message, Request, Response,
6767
readstartline!, writestartline,
6868
bodylength, unknown_length
6969

70-
if VERSION > v"0.7.0-DEV.2338"
71-
using Unicode
72-
end
70+
using ..Unicode
7371

7472
import ..HTTP
7573

src/Servers.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ if !isdefined(Base, :Nothing)
1818
const Cvoid = Void
1919
end
2020

21-
if VERSION < v"0.7.0-DEV.2575"
22-
const Dates = Base.Dates
23-
else
24-
import Dates
25-
end
21+
import ..Dates
22+
2623
@static if !isdefined(Base, :Distributed)
2724
using Distributed
2825
end

src/URIs.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module URIs
22

3-
if VERSION >= v"0.7.0-DEV.2915"
4-
using Unicode
5-
end
3+
using ..Unicode
64

75
import Base.==
86

src/WebSockets.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module WebSockets
22

3-
using Base64
4-
using Unicode
3+
using ..Base64
4+
using ..Unicode
55
using MbedTLS: digest, MD_SHA1, SSLContext
66
import ..HTTP
77
using ..IOExtras
@@ -191,12 +191,12 @@ function wswrite(ws::WebSocket, opcode::UInt8, bytes::Vector{UInt8})
191191
end
192192

193193

194-
function mask!(out, in, l, mask=rand(UInt8, 4))
195-
if length(out) < l
196-
resize!(out, l)
194+
function mask!(to, from, l, mask=rand(UInt8, 4))
195+
if length(to) < l
196+
resize!(to, l)
197197
end
198198
for i in 1:l
199-
out[i] = in[i] mask[((i-1) % 4)+1]
199+
to[i] = from[i] mask[((i-1) % 4)+1]
200200
end
201201
return mask
202202
end

src/compat.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
else # Julia v0.6
88

9+
eval(:(module Base64 end))
10+
eval(:(module Unicode end))
911
const Dates = Base.Dates
12+
1013
pairs(x) = [k => v for (k,v) in x]
1114

1215
macro debug(s) DEBUG_LEVEL > 0 ? :(("D- ", $(esc(s)))) : :() end
@@ -28,4 +31,5 @@ if !isdefined(Base, :Nothing)
2831
const Cvoid = Void
2932
end
3033

34+
# https://github.com/JuliaLang/julia/pull/25535
3135
Base.String(x::SubArray{UInt8,1}) = String(Vector{UInt8}(x))

0 commit comments

Comments
 (0)