diff --git a/src/HTTP.jl b/src/HTTP.jl index 012c90107..04b96b2bd 100644 --- a/src/HTTP.jl +++ b/src/HTTP.jl @@ -31,6 +31,11 @@ if !isdefined(Base, :pairs) pairs(x) = x end +if !isdefined(Base, :Nothing) + const Nothing = Void + const Cvoid = Void +end + if VERSION < v"0.7.0-DEV.2575" const Dates = Base.Dates else diff --git a/src/handlers.jl b/src/handlers.jl index b7f09b019..33173d194 100644 --- a/src/handlers.jl +++ b/src/handlers.jl @@ -1,5 +1,10 @@ module Handlers +if !isdefined(Base, :Nothing) + const Nothing = Void + const Cvoid = Void +end + function val(v) @static if VERSION < v"0.7.0-DEV.1395" Val{v}() @@ -59,7 +64,7 @@ struct Router <: Handler segments::Dict{String, Val} sym::Symbol func::Function - function Router(ff::Union{Handler, Function, Void}=nothing) + function Router(ff::Union{Handler, Function, Nothing}=nothing) sym = gensym() if ff == nothing f = @eval $sym(args...) = FourOhFour diff --git a/src/parser.jl b/src/parser.jl index 55cac9aca..f5cf01fd8 100644 --- a/src/parser.jl +++ b/src/parser.jl @@ -834,8 +834,8 @@ function parse!(r, parser, bytes, len, lenient, host, method, maxuri, maxheader, limit = min(limit, maxheader) ptr = pointer(bytes, p) @debug(PARSING_DEBUG, Base.escape_string(string('\'', Char(bytes[p]), '\''))) - p_cr = ccall(:memchr, Ptr{Void}, (Ptr{Void}, Cint, Csize_t), ptr, CR, limit) - p_lf = ccall(:memchr, Ptr{Void}, (Ptr{Void}, Cint, Csize_t), ptr, LF, limit) + p_cr = ccall(:memchr, Ptr{Cvoid}, (Ptr{Cvoid}, Cint, Csize_t), ptr, CR, limit) + p_lf = ccall(:memchr, Ptr{Cvoid}, (Ptr{Cvoid}, Cint, Csize_t), ptr, LF, limit) @debug(PARSING_DEBUG, limit) @debug(PARSING_DEBUG, Int(p_cr)) @debug(PARSING_DEBUG, Int(p_lf)) diff --git a/src/precompile.jl b/src/precompile.jl index 165b2c3e9..4caf645e6 100644 --- a/src/precompile.jl +++ b/src/precompile.jl @@ -44,7 +44,7 @@ function _precompile_() @assert precompile(HTTP.ignorewhitespace, (Array{UInt8, 1}, Int64, Int64,)) @assert precompile(HTTP.Cookies.String, (HTTP.Cookies.Cookie, Bool,)) @assert precompile(HTTP.Cookies.shouldsend, (HTTP.Cookies.Cookie, Bool, String, String,)) - @assert precompile(HTTP.Client, (Void, HTTP.RequestOptions,)) + @assert precompile(HTTP.Client, (Nothing, HTTP.RequestOptions,)) @assert precompile(HTTP.Cookies.parsecookievalue, (Base.SubString{String}, Bool,)) @assert precompile(HTTP.ignorewhitespace, (Array{UInt8, 1}, UInt64, Int64,)) @assert precompile(HTTP.Cookies.hash, (HTTP.Cookies.Cookie, UInt,)) diff --git a/src/server.jl b/src/server.jl index 449e3cb36..6ae0b8458 100644 --- a/src/server.jl +++ b/src/server.jl @@ -1,5 +1,10 @@ module Nitrogen +if !isdefined(Base, :Nothing) + const Nothing = Void + const Cvoid = Void +end + if VERSION < v"0.7.0-DEV.2575" const Dates = Base.Dates else @@ -47,7 +52,7 @@ mutable struct ServerOptions maxheader::Int64 maxbody::Int64 support100continue::Bool - chunksize::Union{Void, Int} + chunksize::Union{Nothing, Int} logbody::Bool end @@ -58,7 +63,7 @@ ServerOptions(; tlsconfig::HTTP.TLS.SSLConfig=HTTP.TLS.SSLConfig(true), maxheader::Int64=HTTP.DEFAULT_MAX_HEADER, maxbody::Int64=HTTP.DEFAULT_MAX_BODY, support100continue::Bool=true, - chunksize::Union{Void, Int}=nothing, + chunksize::Union{Nothing, Int}=nothing, logbody::Bool=true) = ServerOptions(tlsconfig, readtimeout, ratelimit, maxbody, maxuri, maxheader, support100continue, chunksize, logbody) diff --git a/src/types.jl b/src/types.jl index 80da22676..8a41fd81c 100644 --- a/src/types.jl +++ b/src/types.jl @@ -12,8 +12,8 @@ schemetype(::Type{TLS.SSLContext}) = https const Headers = Dict{String, String} -const Option{T} = Union{T, Void} -not(::Void) = true +const Option{T} = Union{T, Nothing} +not(::Nothing) = true not(x) = false function get(value::T, name::Symbol, default::R)::R where {T, R} val = getfield(value, name)::Option{R} @@ -220,7 +220,7 @@ mutable struct Response cookies::Vector{Cookie} headers::Headers body::FIFOBuffer - request::Union{Void,Request} + request::Union{Nothing,Request} history::Vector{Response} end @@ -247,7 +247,7 @@ Response(; status::Int=200, cookies::Vector{Cookie}=Cookie[], headers::Headers=Headers(), body::FIFOBuffer=FIFOBuffer(""), - request::Union{Void,Request}=nothing, + request::Union{Nothing,Request}=nothing, history::Vector{Response}=Response[]) = Response(status, Int16(1), Int16(1), cookies, headers, body, request, history)