Internal Interfaces
Parser Interface
HTTP.Parsers.find_end_of_header
— Function.find_end_of_header(bytes) -> length or 0
Find length of header delimited by \r\n\r\n
or \n\n
.
HTTP.Parsers.find_end_of_chunk_size
— Function.Find \n
after chunk size in bytes
.
HTTP.Parsers.find_end_of_trailer
— Function.find_end_of_trailer(bytes) -> length or 0
Find length of trailer delimited by \r\n\r\n
(or starting with \r\n
). RFC7230 4.1
HTTP.Parsers.parse_status_line!
— Function.Parse HTTP response-line bytes
and set the status
and version
fields of response
. Return a SubString
containing the header-field lines.
HTTP.Parsers.parse_request_line!
— Function.Parse HTTP request-line bytes
and set the method
, target
and version
fields of request
. Return a SubString
containing the header-field lines.
HTTP.Parsers.parse_header_field
— Function.Parse HTTP header-field. Return Pair(field-name => field-value)
and a SubString
containing the remaining header-field lines.
HTTP.Parsers.parse_chunk_size
— Function.Messages Interface
HTTP.Messages.Request
— Type.Request <: Message
Represents a HTTP Request Message.
method::String
RFC7230 3.1.1target::String
RFC7230 5.3version::VersionNumber
RFC7230 2.6headers::Vector{Pair{String,String}}
RFC7230 3.2body::Vector{UInt8}
RFC7230 3.3response
, theResponse
to thisRequest
txcount
, number of times thisRequest
has been sent (see RetryRequest.jl).parent
, theResponse
(if any) that led to this request (e.g. in the case of a redirect). RFC7230 6.4
HTTP.Messages.Response
— Type.Response <: Message
Represents a HTTP Response Message.
version::VersionNumber
RFC7230 2.6status::Int16
RFC7230 3.1.2 RFC7231 6headers::Vector{Pair{String,String}}
RFC7230 3.2body::Vector{UInt8}
RFC7230 3.3request
, theRequest
that yielded thisResponse
.
HTTP.Messages.iserror
— Function.iserror(::Response)
Does this Response
have an error status?
HTTP.Messages.isredirect
— Function.isredirect(::Response)
Does this Response
have a redirect status?
HTTP.Messages.ischunked
— Function.ischunked(::Message)
Does the Message
have a "Transfer-Encoding: chunked" header?
HTTP.Messages.issafe
— Function.issafe(::Request)
https://tools.ietf.org/html/rfc7231#section-4.2.1
HTTP.Messages.isidempotent
— Function.isidempotent(::Request)
https://tools.ietf.org/html/rfc7231#section-4.2.2
HTTP.Messages.header
— Function.header(::Message, key [, default=""]) -> String
Get header value for key
(case-insensitive).
HTTP.Messages.hasheader
— Function.hasheader(::Message, key) -> Bool
Does header value for key
exist (case-insensitive)?
hasheader(::Message, key, value) -> Bool
Does header for key
match value
(both case-insensitive)?
HTTP.Messages.setheader
— Function.setheader(::Message, key => value)
Set header value
for key
(case-insensitive).
HTTP.Messages.defaultheader!
— Function.defaultheader!(::Message, key => value)
Set header value
in message for key
if it is not already set.
HTTP.Messages.appendheader
— Function.appendheader(::Message, key => value)
Append a header value to message.headers
.
If key
is the same as the previous header, the value
is appended to the value of the previous header with a comma delimiter
Set-Cookie
headers are not comma-combined because cookies often contain internal commas.
HTTP.Messages.readheaders
— Function.readheaders(::IO, ::Message)
Read headers (and startline) from an IO
stream into a Message
struct. Throw EOFError
if input is incomplete.
HTTP.MessageRequest.setuseragent!
— Function.setuseragent!(x::Union{String, Nothing})
Set the default User-Agent string to be used in each HTTP request. Can be manually overridden by passing an explicit User-Agent
header. Setting nothing
will prevent the default User-Agent
header from being passed.
HTTP.Messages.readchunksize
— Function.Read chunk-size from an IO
stream. After the final zero size chunk, read trailers into a Message
struct.
HTTP.Messages.headerscomplete
— Method.headerscomplete(::Message)
Have the headers been read into this Message
?
HTTP.Messages.writestartline
— Function.writestartline(::IO, ::Message)
e.g. "GET /path HTTP/1.1\r\n"
or "HTTP/1.1 200 OK\r\n"
HTTP.Messages.writeheaders
— Function.writeheaders(::IO, ::Message)
Write Message
start line and a line for each "name: value" pair and a trailing blank line.
Base.write
— Method.write(::IO, ::Message)
Write start line, headers and body of HTTP Message.
IOExtras Interface
HTTP.IOExtras
— Module.IOExtras
This module defines extensions to the Base.IO
interface to support:
startwrite
,closewrite
,startread
andcloseread
for streams with transactional semantics.
HTTP.IOExtras.startwrite
— Method.startwrite(::IO)
closewrite(::IO)
startread(::IO)
closeread(::IO)
Signal start/end of write or read operations.
HTTP.IOExtras.isioerror
— Function.isioerror(exception)
Is exception
caused by a possibly recoverable IO error.
Streams Interface
HTTP.Streams.closebody
— Function.closebody(::Stream)
Write the final 0
chunk if needed.
HTTP.Streams.isaborted
— Function.isaborted(::Stream{Response})
Has the server signaled that it does not wish to receive the message body?
"If [the response] indicates the server does not wish to receive the message body and is closing the connection, the client SHOULD immediately cease transmitting the body and close the connection." RFC7230, 6.5
Connection Pooling Interface
HTTP.ConnectionPool.Connection
— Type.Connection{T <: IO}
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.idle_timeout
, No. of seconds to maintain connection after last transaction.peerport
, remote TCP port number (used for debug messages).localport
, local TCP port number (used for debug messages).io::T
, theTCPSocket
or `SSLContext.clientconnection::Bool
, whether the Connection was created from client code (as opposed to server code)buffer::IOBuffer
, left over bytes read from the connection after the end of a response header (or chunksize). These bytes are usually part of the response body.sequence
, number of most recentTransaction
.writecount
, number of Messages that have been written, protected bywritelock
writelock
, lock writecount and writebusy, and signal thatwritecount
was incremented.writebusy
, whether a Transaction currently holds the Connection write lock, protected bywritelock
readcount
, number of Messages that have been read, protected byreadlock
readlock
, lock readcount and readbusy, and signal thatreadcount
was incremented.readbusy
, whether a Transaction currently holds the Connection read lock, protectecd byreadlock
timestamp
, time data was last received.
HTTP.ConnectionPool.Transaction
— Type.Transaction
A single pipelined HTTP Request/Response transaction.
Fields:
c
, the sharedConnection
used for thisTransaction
.sequence::Int
, identifies thisTransaction
among the others that sharec
.writebusy::Bool
, whether this Transaction holds its parent Connection write lock, protected by c.writelockreadbusy::Bool
, whether this Transaction holds its parent Connection read lock, protected by c.readlock
Missing docstring for HTTP.ConnectionPool.pool
. Check Documenter's build log for details.
HTTP.ConnectionPool.getconnection
— Function.getconnection(type, host, port) -> Connection
Find a reusable Connection
in the pool
, or create a new Connection
if required.
HTTP.IOExtras.startwrite
— Method.startwrite(::Transaction)
Wait for prior pending writes to complete.
HTTP.IOExtras.closewrite
— Method.closewrite(::Transaction)
Signal that an entire Request Message has been written to the Transaction
.
HTTP.IOExtras.startread
— Method.startread(::Transaction)
Wait for prior pending reads to complete.
HTTP.IOExtras.closeread
— Method.closeread(::Transaction)
Signal that an entire Response Message has been read from the Transaction
.
Increment readcount
and wake up tasks waiting in startread
.