Skip to content

Commit

Permalink
Undo Sockets.TCP
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed Mar 5, 2018
1 parent 766cbf9 commit cb2cef2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/ConnectionPool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct to manage pipelining and connection reuse and a
pipelined request. Methods are provided for `eof`, `readavailable`,
`unsafe_write` and `close`.
This allows the `Transaction` object to act as a proxy for the
`Sockets.TCP` or `SSLContext` that it wraps.
`TCPSocket` or `SSLContext` that it wraps.
The [`pool`](@ref) is a collection of open
`Connection`s. The `request` function calls `getconnection` to
Expand Down Expand Up @@ -45,15 +45,15 @@ byteview(bytes)::ByteView = view(bytes, 1:length(bytes))
"""
Connection{T <: IO}
A `Sockets.TCP` or `SSLContext` connection to a HTTP `host` and `port`.
A `TCPSocket` or `SSLContext` connection to a HTTP `host` and `port`.
Fields:
- `host::String`
- `port::String`, exactly as specified in the URI (i.e. may be empty).
- `pipeline_limit`, number of requests to send before waiting for responses.
- `peerport`, remote TCP port number (used for debug messages).
- `localport`, local TCP port number (used for debug messages).
- `io::T`, the `Sockets.TCP` or `SSLContext.
- `io::T`, the `TCPSocket` or `SSLContext.
- `excess::ByteView`, left over bytes read from the connection after
the end of a response message. These bytes are probably the start of the
next response message.
Expand Down Expand Up @@ -459,11 +459,11 @@ function keepalive!(tcp)
return
end

function getconnection(::Type{Sockets.TCP},
function getconnection(::Type{TCPSocket},
host::AbstractString,
port::AbstractString;
keepalive::Bool=false,
kw...)::Sockets.TCP
kw...)::TCPSocket
p::UInt = isempty(port) ? UInt(80) : parse(UInt, port)
@debug 2 "TCP connect: $host:$p..."
tcp = Sockets.connect(Sockets.getaddrinfo(host), p)
Expand Down Expand Up @@ -500,7 +500,7 @@ function getconnection(::Type{SSLContext},
@debug 2 "SSL connect: $host:$port..."
io = SSLContext()
setup!(io, sslconfig)
associate!(io, getconnection(Sockets.TCP, host, port; kw...))
associate!(io, getconnection(TCPSocket, host, port; kw...))
hostname!(io, host)
handshake!(io)
return io
Expand Down
2 changes: 1 addition & 1 deletion src/ConnectionRequest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract type ConnectionPoolLayer{Next <: Layer} <: Layer end
export ConnectionPoolLayer

function request(::Type{ConnectionPoolLayer{Next}}, url::URI, req, body;
socket_type::Type=Sockets.TCP, kw...) where Next
socket_type::Type=TCPSocket, kw...) where Next

IOType = ConnectionPool.Transaction{sockettype(url, socket_type)}
io = getconnection(IOType, url.host, url.port; kw...)
Expand Down
4 changes: 2 additions & 2 deletions src/IOExtras.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ start_close_read_write_doc
closeread(io) = nothing

using MbedTLS: SSLContext
tcpsocket(io::SSLContext)::Sockets.TCP = io.bio
tcpsocket(io::Sockets.TCP)::Sockets.TCP = io
tcpsocket(io::SSLContext)::TCPSocket = io.bio
tcpsocket(io::TCPSocket)::TCPSocket = io

localport(io) = try !isopen(tcpsocket(io)) ? 0 :
VERSION > v"0.7.0-DEV" ?
Expand Down
2 changes: 1 addition & 1 deletion src/Servers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ Optional keyword arguments:
- `pipeline_limit = 16`, number of concurrent requests per connection.
- `reuse_limit = nolimit`, number of times a connection is allowed to be reused
after the first request.
- `tcpisvalid::Function (::Sockets.TCP) -> Bool`, check accepted connection before
- `tcpisvalid::Function (::TCPSocket) -> Bool`, check accepted connection before
processing requests. e.g. to implement source IP filtering, rate-limiting,
etc.
- `tcpref::Ref{Sockets.TCPServer}`, this reference is set to the underlying
Expand Down
3 changes: 1 addition & 2 deletions src/compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ __init__() = supported() || compat_warn()

compat_search(s::AbstractString, c::Char) = Base.findfirst(equalto(c), s)
using Sockets
eval(Sockets, :(const TCP = TCPSocket))

else

Expand Down Expand Up @@ -64,9 +63,9 @@ else
Base.fetch(t::Task) = wait(t)

eval(:(module Sockets
export TCPSocket
import Base: TCPSocket, TCPServer, IPAddr, @ip_str, DNSError,
getsockname, getaddrinfo, connect, listen, DNSError
const TCP = TCPSocket
end))
using .Sockets
end
Expand Down

0 comments on commit cb2cef2

Please sign in to comment.