Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 86cbd5c141 | |||
| 84b9c5d64d | |||
| 4f402dbb57 |
@@ -73,5 +73,3 @@ fastlane/test_output
|
||||
*.orig
|
||||
/.idea
|
||||
/Package.pins
|
||||
/Package.resolved
|
||||
docs
|
||||
|
||||
+3
-5
@@ -12,16 +12,14 @@ readme: README.md
|
||||
skip_undocumented: false
|
||||
hide_documentation_coverage: false
|
||||
|
||||
xcodebuild_arguments: [-project, SwiftServerHTTP.xcodeproj, -target, HTTP]
|
||||
xcodebuild_arguments: [-project, SwiftServerHTTP.xcodeproj, -target, HTTP, LIBRARY_SEARCH_PATHS=.build/debug]
|
||||
|
||||
custom_categories:
|
||||
|
||||
- name: HTTP Server
|
||||
children:
|
||||
- HTTPServer
|
||||
- HTTPServing
|
||||
- HTTPRequestHandler
|
||||
- HTTPRequestHandling
|
||||
- WebAppContaining
|
||||
- WebApp
|
||||
|
||||
- name: HTTP Headers
|
||||
children:
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
4.0
|
||||
3.1.1-RELEASE
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
included:
|
||||
- Sources
|
||||
- Tests
|
||||
|
||||
opt_in_rules:
|
||||
- closure_end_indentation
|
||||
- closure_spacing
|
||||
- fatal_error_message
|
||||
- operator_usage_whitespace
|
||||
- redundant_nil_coalescing
|
||||
- switch_case_on_newline
|
||||
- attributes
|
||||
- no_extension_access_modifier
|
||||
|
||||
disabled_rules:
|
||||
- trailing_comma
|
||||
- line_length
|
||||
- file_length
|
||||
- function_body_length
|
||||
- type_body_length
|
||||
- todo
|
||||
|
||||
identifier_name:
|
||||
excluded:
|
||||
- i
|
||||
- ok
|
||||
- im
|
||||
- if
|
||||
- te
|
||||
|
||||
large_tuple: 4
|
||||
|
||||
cyclomatic_complexity: 15
|
||||
|
||||
nesting:
|
||||
type_level: 2
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
branches:
|
||||
except:
|
||||
- gh-pages
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
dist: trusty
|
||||
sudo: required
|
||||
- os: osx
|
||||
osx_image: xcode9
|
||||
|
||||
before_install:
|
||||
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -y ; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://swift.org/builds/swift-4.0-release/ubuntu1404/swift-4.0-RELEASE/swift-4.0-RELEASE-ubuntu14.04.tar.gz ; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tar xzvf swift-4.0-RELEASE-ubuntu14.04.tar.gz ; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export PATH=swift-4.0-RELEASE-ubuntu14.04/usr/bin:$PATH ; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -y install clang libicu-dev ; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CC=/usr/bin/clang; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CXX=/usr/bin/clang ; fi
|
||||
|
||||
script:
|
||||
- swift build
|
||||
- swift test
|
||||
@@ -1,412 +0,0 @@
|
||||
```
|
||||
/// HTTP Request NOT INCLUDING THE BODY. This allows for streaming
|
||||
public struct HTTPRequest {
|
||||
public var method : HTTPMethod
|
||||
public var target : String /* e.g. "/foo/bar?buz=qux" */
|
||||
public var httpVersion : HTTPVersion
|
||||
public var headers : HTTPHeaders
|
||||
}
|
||||
|
||||
/// Object that code writes the response and response body to.
|
||||
public protocol HTTPResponseWriter : class {
|
||||
func writeHeader(status: HTTPResponseStatus, headers: HTTPHeaders, completion: @escaping (Result) -> Void)
|
||||
func writeTrailer(_ trailers: HTTPHeaders, completion: @escaping (Result) -> Void)
|
||||
func writeBody(_ data: UnsafeHTTPResponseBody, completion: @escaping (Result) -> Void)
|
||||
func done(completion: @escaping (Result) -> Void)
|
||||
func abort()
|
||||
}
|
||||
|
||||
/// Convenience methods for HTTP response writer.
|
||||
extension HTTPResponseWriter {
|
||||
public func writeHeader(status: HTTPResponseStatus, headers: HTTPHeaders)
|
||||
public func writeHeader(status: HTTPResponseStatus)
|
||||
public func writeTrailer(_ trailers: HTTPHeaders)
|
||||
public func writeBody(_ data: UnsafeHTTPResponseBody)
|
||||
public func done()
|
||||
}
|
||||
|
||||
public protocol UnsafeHTTPResponseBody {
|
||||
func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R
|
||||
}
|
||||
|
||||
extension UnsafeRawBufferPointer : UnsafeHTTPResponseBody {
|
||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R
|
||||
}
|
||||
|
||||
public protocol HTTPResponseBody : UnsafeHTTPResponseBody {}
|
||||
|
||||
extension Data : HTTPResponseBody {
|
||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R
|
||||
}
|
||||
|
||||
extension DispatchData : HTTPResponseBody {
|
||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R
|
||||
}
|
||||
|
||||
extension String : HTTPResponseBody {
|
||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R
|
||||
}
|
||||
|
||||
/// Method that takes a chunk of request body and is expected to write to the ResponseWriter
|
||||
public typealias HTTPBodyHandler = (HTTPBodyChunk, inout Bool) -> Void /* the Bool can be set to true when we don't want to process anything further */
|
||||
|
||||
/// Indicates whether the body is going to be processed or ignored
|
||||
public enum HTTPBodyProcessing {
|
||||
case discardBody /* if you're not interested in the body */
|
||||
case processBody(handler: HTTPBodyHandler)
|
||||
}
|
||||
|
||||
/// Part (or maybe all) of the incoming request body
|
||||
public enum HTTPBodyChunk {
|
||||
case chunk(data: DispatchData, finishedProcessing: () -> Void) /* a new bit of the HTTP request body has arrived, finishedProcessing() must be called when done with that chunk */
|
||||
case failed(error: /*HTTPParser*/ Error) /* error while streaming the HTTP request body, eg. connection closed */
|
||||
case trailer(key: String, value: String) /* trailer has arrived (this we actually haven't implemented yet) */
|
||||
case end /* body and trailers finished */
|
||||
}
|
||||
|
||||
/// Headers structure.
|
||||
public struct HTTPHeaders : Sequence, ExpressibleByDictionaryLiteral {
|
||||
public subscript(name: Name) -> String?
|
||||
public subscript(valuesFor name: Name) -> [String]
|
||||
|
||||
public struct Literal : ExpressibleByDictionaryLiteral { }
|
||||
public mutating func append(_ literal: HTTPHeaders.Literal)
|
||||
public mutating func replace(_ literal: HTTPHeaders.Literal)
|
||||
|
||||
public func makeIterator() -> AnyIterator<(name: Name, value: String)>
|
||||
|
||||
public struct Name : Hashable, ExpressibleByStringLiteral, CustomStringConvertible {
|
||||
public init(_ name: String)
|
||||
|
||||
// https://www.iana.org/assignments/message-headers/message-headers.xhtml
|
||||
// Permanent Message Header Field Names
|
||||
public static let aIM
|
||||
public static let accept
|
||||
public static let acceptAdditions
|
||||
public static let acceptCharset
|
||||
public static let acceptDatetime
|
||||
public static let acceptEncoding
|
||||
public static let acceptFeatures
|
||||
public static let acceptLanguage
|
||||
public static let acceptPatch
|
||||
public static let acceptPost
|
||||
public static let acceptRanges
|
||||
public static let age
|
||||
public static let allow
|
||||
public static let alpn
|
||||
public static let altSvc
|
||||
public static let altUsed
|
||||
public static let alternates
|
||||
public static let applyToRedirectRef
|
||||
public static let authenticationControl
|
||||
public static let authenticationInfo
|
||||
public static let authorization
|
||||
public static let cExt
|
||||
public static let cMan
|
||||
public static let cOpt
|
||||
public static let cPEP
|
||||
public static let cPEPInfo
|
||||
public static let cacheControl
|
||||
public static let calDAVTimezones
|
||||
public static let close
|
||||
public static let connection
|
||||
public static let contentBase
|
||||
public static let contentDisposition
|
||||
public static let contentEncoding
|
||||
public static let contentID
|
||||
public static let contentLanguage
|
||||
public static let contentLength
|
||||
public static let contentLocation
|
||||
public static let contentMD5
|
||||
public static let contentRange
|
||||
public static let contentScriptType
|
||||
public static let contentStyleType
|
||||
public static let contentType
|
||||
public static let contentVersion
|
||||
public static let cookie
|
||||
public static let cookie2
|
||||
public static let dasl
|
||||
public static let dav
|
||||
public static let date
|
||||
public static let defaultStyle
|
||||
public static let deltaBase
|
||||
public static let depth
|
||||
public static let derivedFrom
|
||||
public static let destination
|
||||
public static let differentialID
|
||||
public static let digest
|
||||
public static let eTag
|
||||
public static let expect
|
||||
public static let expires
|
||||
public static let ext
|
||||
public static let forwarded
|
||||
public static let from
|
||||
public static let getProfile
|
||||
public static let hobareg
|
||||
public static let host
|
||||
public static let http2Settings
|
||||
public static let im
|
||||
public static let `if`
|
||||
public static let ifMatch
|
||||
public static let ifModifiedSince
|
||||
public static let ifNoneMatch
|
||||
public static let ifRange
|
||||
public static let ifScheduleTagMatch
|
||||
public static let ifUnmodifiedSince
|
||||
public static let keepAlive
|
||||
public static let label
|
||||
public static let lastModified
|
||||
public static let link
|
||||
public static let location
|
||||
public static let lockToken
|
||||
public static let man
|
||||
public static let maxForwards
|
||||
public static let mementoDatetime
|
||||
public static let meter
|
||||
public static let mimeVersion
|
||||
public static let negotiate
|
||||
public static let opt
|
||||
public static let optionalWWWAuthenticate
|
||||
public static let orderingType
|
||||
public static let origin
|
||||
public static let overwrite
|
||||
public static let p3p
|
||||
public static let pep
|
||||
public static let picsLabel
|
||||
public static let pepInfo
|
||||
public static let position
|
||||
public static let pragma
|
||||
public static let prefer
|
||||
public static let preferenceApplied
|
||||
public static let profileObject
|
||||
public static let `protocol`
|
||||
public static let protocolInfo
|
||||
public static let protocolQuery
|
||||
public static let protocolRequest
|
||||
public static let proxyAuthenticate
|
||||
public static let proxyAuthenticationInfo
|
||||
public static let proxyAuthorization
|
||||
public static let proxyFeatures
|
||||
public static let proxyInstruction
|
||||
public static let `public`
|
||||
public static let publicKeyPins
|
||||
public static let publicKeyPinsReportOnly
|
||||
public static let range
|
||||
public static let redirectRef
|
||||
public static let referer
|
||||
public static let retryAfter
|
||||
public static let safe
|
||||
public static let scheduleReply
|
||||
public static let scheduleTag
|
||||
public static let secWebSocketAccept
|
||||
public static let secWebSocketExtensions
|
||||
public static let secWebSocketKey
|
||||
public static let secWebSocketProtocol
|
||||
public static let secWebSocketVersion
|
||||
public static let securityScheme
|
||||
public static let server
|
||||
public static let setCookie
|
||||
public static let setCookie2
|
||||
public static let setProfile
|
||||
public static let slug
|
||||
public static let soapAction
|
||||
public static let statusURI
|
||||
public static let strictTransportSecurity
|
||||
public static let surrogateCapability
|
||||
public static let surrogateControl
|
||||
public static let tcn
|
||||
public static let te
|
||||
public static let timeout
|
||||
public static let topic
|
||||
public static let trailer
|
||||
public static let transferEncoding
|
||||
public static let ttl
|
||||
public static let urgency
|
||||
public static let uri
|
||||
public static let upgrade
|
||||
public static let userAgent
|
||||
public static let variantVary
|
||||
public static let vary
|
||||
public static let via
|
||||
public static let wwwAuthenticate
|
||||
public static let wantDigest
|
||||
public static let warning
|
||||
public static let xFrameOptions
|
||||
|
||||
// https://www.iana.org/assignments/message-headers/message-headers.xhtml
|
||||
// Provisional Message Header Field Names
|
||||
public static let accessControl
|
||||
public static let accessControlAllowCredentials
|
||||
public static let accessControlAllowHeaders
|
||||
public static let accessControlAllowMethods
|
||||
public static let accessControlAllowOrigin
|
||||
public static let accessControlMaxAge
|
||||
public static let accessControlRequestMethod
|
||||
public static let accessControlRequestHeaders
|
||||
public static let compliance
|
||||
public static let contentTransferEncoding
|
||||
public static let cost
|
||||
public static let ediintFeatures
|
||||
public static let messageID
|
||||
public static let methodCheck
|
||||
public static let methodCheckExpires
|
||||
public static let nonCompliance
|
||||
public static let optional
|
||||
public static let refererRoot
|
||||
public static let resolutionHint
|
||||
public static let resolverLocation
|
||||
public static let subOK
|
||||
public static let subst
|
||||
public static let title
|
||||
public static let uaColor
|
||||
public static let uaMedia
|
||||
public static let uaPixels
|
||||
public static let uaResolution
|
||||
public static let uaWindowpixels
|
||||
public static let version
|
||||
public static let xDeviceAccept
|
||||
public static let xDeviceAcceptCharset
|
||||
public static let xDeviceAcceptEncoding
|
||||
public static let xDeviceAcceptLanguage
|
||||
public static let xDeviceUserAgent
|
||||
}
|
||||
}
|
||||
|
||||
/// Version number of the HTTP Protocol
|
||||
public struct HTTPVersion {
|
||||
/// Major version component.
|
||||
public var major: Int
|
||||
/// Minor version component.
|
||||
public var minor: Int
|
||||
|
||||
public init(major: Int, minor: Int)
|
||||
}
|
||||
|
||||
public enum HTTPTransferEncoding {
|
||||
case identity(contentLength: UInt)
|
||||
case chunked
|
||||
}
|
||||
|
||||
/// Response status (200 ok, 404 not found, etc)
|
||||
public struct HTTPResponseStatus: Equatable, CustomStringConvertible, ExpressibleByIntegerLiteral {
|
||||
public let code: Int
|
||||
public let reasonPhrase: String
|
||||
|
||||
public init(code: Int, reasonPhrase: String)
|
||||
public init(code: Int)
|
||||
|
||||
/* all the codes from http://www.iana.org/assignments/http-status-codes */
|
||||
public static let `continue`
|
||||
public static let switchingProtocols
|
||||
public static let ok
|
||||
public static let created
|
||||
public static let accepted
|
||||
public static let nonAuthoritativeInformation
|
||||
public static let noContent
|
||||
public static let resetContent
|
||||
public static let partialContent
|
||||
public static let multiStatus
|
||||
public static let alreadyReported
|
||||
public static let imUsed
|
||||
public static let multipleChoices
|
||||
public static let movedPermanently
|
||||
public static let found
|
||||
public static let seeOther
|
||||
public static let notModified
|
||||
public static let useProxy
|
||||
public static let temporaryRedirect
|
||||
public static let permanentRedirect
|
||||
public static let badRequest
|
||||
public static let unauthorized
|
||||
public static let paymentRequired
|
||||
public static let forbidden
|
||||
public static let notFound
|
||||
public static let methodNotAllowed
|
||||
public static let notAcceptable
|
||||
public static let proxyAuthenticationRequired
|
||||
public static let requestTimeout
|
||||
public static let conflict
|
||||
public static let gone
|
||||
public static let lengthRequired
|
||||
public static let preconditionFailed
|
||||
public static let payloadTooLarge
|
||||
public static let uriTooLong
|
||||
public static let unsupportedMediaType
|
||||
public static let rangeNotSatisfiable
|
||||
public static let expectationFailed
|
||||
public static let misdirectedRequest
|
||||
public static let unprocessableEntity
|
||||
public static let locked
|
||||
public static let failedDependency
|
||||
public static let upgradeRequired
|
||||
public static let preconditionRequired
|
||||
public static let tooManyRequests
|
||||
public static let requestHeaderFieldsTooLarge
|
||||
public static let unavailableForLegalReasons
|
||||
public static let internalServerError
|
||||
public static let notImplemented
|
||||
public static let badGateway
|
||||
public static let serviceUnavailable
|
||||
public static let gatewayTimeout
|
||||
public static let httpVersionNotSupported
|
||||
public static let variantAlsoNegotiates
|
||||
public static let insufficientStorage
|
||||
public static let loopDetected
|
||||
public static let notExtended
|
||||
public static let networkAuthenticationRequired
|
||||
|
||||
public var `class`: Class
|
||||
|
||||
public enum Class {
|
||||
case informational
|
||||
case successful
|
||||
case redirection
|
||||
case clientError
|
||||
case serverError
|
||||
case invalidStatus
|
||||
}
|
||||
}
|
||||
|
||||
/// HTTP Methods handled by http_parser.[ch] supports
|
||||
public struct HTTPMethod : Hashable, CustomStringConvertible, ExpressibleByIntegerLiteral {
|
||||
|
||||
public let method: String
|
||||
|
||||
public init(_ method: String)
|
||||
|
||||
/* Constants for everything that http_parser.[ch] supports */
|
||||
public static let delete
|
||||
public static let get
|
||||
public static let head
|
||||
public static let post
|
||||
public static let put
|
||||
public static let connect
|
||||
public static let options
|
||||
public static let trace
|
||||
public static let copy
|
||||
public static let lock
|
||||
public static let mkcol
|
||||
public static let move
|
||||
public static let propfind
|
||||
public static let proppatch
|
||||
public static let search
|
||||
public static let unlock
|
||||
public static let bind
|
||||
public static let rebind
|
||||
public static let unbind
|
||||
public static let acl
|
||||
public static let report
|
||||
public static let mkactivity
|
||||
public static let checkout
|
||||
public static let merge
|
||||
public static let msearch
|
||||
public static let notify
|
||||
public static let subscribe
|
||||
public static let unsubscribe
|
||||
public static let patch
|
||||
public static let purge
|
||||
public static let mkcalendar
|
||||
public static let link
|
||||
public static let unlink
|
||||
}
|
||||
```
|
||||
@@ -1,74 +0,0 @@
|
||||
# Create self-signed certificate with openssl
|
||||
|
||||
```
|
||||
// generate an RSA key
|
||||
openssl genrsa -out key.pem 2048
|
||||
|
||||
// create cert signing request used to generate the cert
|
||||
openssl req -new -sha256 -key key.pem -out cert.csr
|
||||
|
||||
// create cert
|
||||
openssl req -x509 -sha256 -days 365 -key key.pem -in cert.csr -out cert.pem
|
||||
|
||||
// convert cert into PKCS#12 format:
|
||||
openssl pkcs12 -export -out cert.pfx -inkey key.pem -in cert.pem
|
||||
```
|
||||
sw!ft!sC00l
|
||||
|
||||
Alternatively, use: https://www.sslshopper.com/ssl-converter.html
|
||||
|
||||
# Create certificate chain CA->intermediate->server
|
||||
// Based on https://jamielinux.com/docs/openssl-certificate-authority/introduction.html
|
||||
// Use above link to
|
||||
|
||||
```
|
||||
// create root key
|
||||
openssl genrsa -out ca.key.pem 4096
|
||||
|
||||
//create root certificate
|
||||
openssl req -config openssl.cnf -key ca.key.pem -new -x509 -days 7300 -sha256 extensions v3_ca -out ca.cert.pem
|
||||
|
||||
//verify root cert
|
||||
openssl x509 -noout -text -in ca.cert.pem
|
||||
|
||||
// create intermediate key
|
||||
openssl genrsa -out intermediate/intermediate.key.pem 4096
|
||||
|
||||
// create a certificate signing request
|
||||
openssl req -config intermediate/openssl.cnf -new -sha256 -key intermediate/intermediate.key.pem -out intermediate/intermediate.csr.pem
|
||||
|
||||
// create certificate
|
||||
openssl ca -config openssl.cnf -extensions v3_intermediate_ca -days 3650 -notext -md sha256 -in intermediate/intermediate.csr.pem -out intermediate/intermediate.cert.pem
|
||||
|
||||
// verify intermediate certificate
|
||||
openssl x509 -noout -text -in intermediate/intermediate.cert.pem
|
||||
|
||||
// verify intermediate certificate against the root certificate
|
||||
openssl verify -CAfile ca.cert.pem intermediate/intermediate.cert.pem
|
||||
|
||||
// create the certificate chain
|
||||
cat intermediate/intermediate.cert.pem ca.cert.pem > intermediate/ca-chain.cert.pem
|
||||
|
||||
// create server key
|
||||
openssl genrsa -out intermediate/server.key.pem 2048
|
||||
|
||||
openssl req -config intermediate/openssl.cnf -key intermediate/server.key.pem -new -sha256 -out intermediate/server.csr.pem
|
||||
|
||||
openssl ca -config intermediate/openssl.cnf -extensions server_cert -days 375 -notext -md sha256 -in intermediate/server.csr.pem -out intermediate/server.cert.pem
|
||||
|
||||
// verify cert
|
||||
openssl x509 -noout -text -in server.cert.pem
|
||||
|
||||
// verify chain of trust
|
||||
openssl verify -CAfile ca-chain.cert.pem server.cert.pem
|
||||
|
||||
|
||||
// Convert to PKCS12 for testing on mac
|
||||
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt
|
||||
|
||||
or better yet! use: https://www.sslshopper.com/ssl-converter.html
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIICtTCCAZ0CAQAwcDELMAkGA1UEBhMCVVMxEzARBgNVBAgTClNvbWUtU3RhdGUx
|
||||
EjAQBgNVBAoTCVN3aWZ0Lm9yZzEeMBwGA1UECxMVU3dpZnQub3JnIFNlcnZlciBB
|
||||
UElzMRgwFgYDVQQDEw9UTFNTZXJ2aWNlIEFQSXMwggEiMA0GCSqGSIb3DQEBAQUA
|
||||
A4IBDwAwggEKAoIBAQDD+dYrPDCSrXMqK1eXReDpuf5KzMnrzhzNInCGUDQkfchv
|
||||
B/sp/OzP//bnYhIGlBdlbiQyxnW30Q7I/xlfFbIs4P7Rje/szUC03/OiJM4RN36W
|
||||
ry7iO38vH9LO8JlTjGhJ+AMEgdmcfhMDeuaWYUcnh3sPyQ9CLRCzFbAtvIKC9U/h
|
||||
HSaBEricbvunJ91pdxTMloPwEN+5qH2lDbyuYI2mJgdxtkXuDpoOMt0qdqORyiqv
|
||||
t0YUQvQyLzQCGUwiP71aBO9auVrpqE9rHcqN4N3pP0eSjMWzbUptfTNrydz06Eom
|
||||
RFSeha0QKgvK4ka4J0ONvvnTqM8SJDM5Nv3WQ1s9AgMBAAGgADANBgkqhkiG9w0B
|
||||
AQsFAAOCAQEANDOSLVOj7r9Ct0vHQTaP/Jm29Fm0D/C0HT5RfRpDF2NP5SPKUYU5
|
||||
Gnzy4CXfIVDOLqZ5T3fCYnyAfeEBrtjO3Ygnw7Qbfu/rRJgqkX87Vq71IvEvQHls
|
||||
H5JHMqBJT5m9S8fdqS04XFYZoqvrdPNp8vtFWvUjQ5m0bdw+qAE1p+RV+rWIjHnT
|
||||
FZ7D+DZKjKRaanbP2iNX8wlqdg8+/HhY2MDdSscFP8EZwu7mAEIt2J0ZNuMPIN4Y
|
||||
4BzzYEgh4rzWd7FwYPhl9+t3EwUSJPqo5B9Ar7CUZ1bvbVjjU63mG68Aa68S7KdZ
|
||||
C3qVAaiYpRku5b1K/VAuM17/ahaFZGfhHw==
|
||||
-----END CERTIFICATE REQUEST-----
|
||||
@@ -1,25 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEOzCCAyOgAwIBAgIJAPkaoUuAHqnVMA0GCSqGSIb3DQEBCwUAMHAxCzAJBgNV
|
||||
BAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQKEwlTd2lmdC5vcmcx
|
||||
HjAcBgNVBAsTFVN3aWZ0Lm9yZyBTZXJ2ZXIgQVBJczEYMBYGA1UEAxMPVExTU2Vy
|
||||
dmljZSBBUElzMCAXDTE3MDYwNTE0MzcwNFoYDzIxMTcwNTEyMTQzNzA0WjBwMQsw
|
||||
CQYDVQQGEwJVUzETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEChMJU3dpZnQu
|
||||
b3JnMR4wHAYDVQQLExVTd2lmdC5vcmcgU2VydmVyIEFQSXMxGDAWBgNVBAMTD1RM
|
||||
U1NlcnZpY2UgQVBJczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMP5
|
||||
1is8MJKtcyorV5dF4Om5/krMyevOHM0icIZQNCR9yG8H+yn87M//9udiEgaUF2Vu
|
||||
JDLGdbfRDsj/GV8Vsizg/tGN7+zNQLTf86IkzhE3fpavLuI7fy8f0s7wmVOMaEn4
|
||||
AwSB2Zx+EwN65pZhRyeHew/JD0ItELMVsC28goL1T+EdJoESuJxu+6cn3Wl3FMyW
|
||||
g/AQ37mofaUNvK5gjaYmB3G2Re4Omg4y3Sp2o5HKKq+3RhRC9DIvNAIZTCI/vVoE
|
||||
71q5WumoT2sdyo3g3ek/R5KMxbNtSm19M2vJ3PToSiZEVJ6FrRAqC8riRrgnQ42+
|
||||
+dOozxIkMzk2/dZDWz0CAwEAAaOB1TCB0jAdBgNVHQ4EFgQUjuA8rn7EEEK2aSl2
|
||||
LzcHT3bIpKIwgaIGA1UdIwSBmjCBl4AUjuA8rn7EEEK2aSl2LzcHT3bIpKKhdKRy
|
||||
MHAxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQKEwlT
|
||||
d2lmdC5vcmcxHjAcBgNVBAsTFVN3aWZ0Lm9yZyBTZXJ2ZXIgQVBJczEYMBYGA1UE
|
||||
AxMPVExTU2VydmljZSBBUElzggkA+RqhS4AeqdUwDAYDVR0TBAUwAwEB/zANBgkq
|
||||
hkiG9w0BAQsFAAOCAQEAtWnk3Z3Ae6FuhGLwLAFiWQ3p+JK2mGP7BjnnyoJzuXiy
|
||||
NIgMru6vJb/3O+xO3TTypRLcGHgHZgRc16VBIw4rgO2/Kr8Ij5N84L3TL+7o3hLc
|
||||
0JRb+3jOADAC5LbDVKkW8li1CKFbg3H6B++9ccs72GsGSSBOCnYegUU7sc32roWo
|
||||
0f1P8JjDntX4bPzzAIprVjENXx4WZf2VNGJbTsRf3lsU9/ROJwuJhuBWDDe0H657
|
||||
guWIMDbxVlJoNciNH4Xxr8GNRpb97SHrgT+bNnO8uq4MT7q5xDAx452v4wJYG/B4
|
||||
Iej9MelHCb0L9etQ0N9/GGJyyUD1ZDRTkup5iMsT/A==
|
||||
-----END CERTIFICATE-----
|
||||
Binary file not shown.
@@ -1,27 +0,0 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEowIBAAKCAQEAw/nWKzwwkq1zKitXl0Xg6bn+SszJ684czSJwhlA0JH3Ibwf7
|
||||
Kfzsz//252ISBpQXZW4kMsZ1t9EOyP8ZXxWyLOD+0Y3v7M1AtN/zoiTOETd+lq8u
|
||||
4jt/Lx/SzvCZU4xoSfgDBIHZnH4TA3rmlmFHJ4d7D8kPQi0QsxWwLbyCgvVP4R0m
|
||||
gRK4nG77pyfdaXcUzJaD8BDfuah9pQ28rmCNpiYHcbZF7g6aDjLdKnajkcoqr7dG
|
||||
FEL0Mi80AhlMIj+9WgTvWrla6ahPax3KjeDd6T9HkozFs21KbX0za8nc9OhKJkRU
|
||||
noWtECoLyuJGuCdDjb7506jPEiQzOTb91kNbPQIDAQABAoIBAETt/Blq6z68CTS8
|
||||
1+saJfivdbTDgQYSkejJA0EKtrxbDYOYEAx9rKGgSyypPuPXdL81VUASs9b6jjO+
|
||||
HiNmkyvb22TDgq8MpoS3/I58WYqOtVS0u03RVXOywsgMsjFDwm657/3G2k6DvZZM
|
||||
xQwBnTBXI76ynk5NYYFL0JLVqiX7GxLHRP0vWIemi+nsLDxNuH2Z03dZcaT/crAi
|
||||
C8OyxKqYjnPRQsWmfrIaqstFlB+saj41P5k1MprHFOeoYv5zRQ+vJI34X+tw/xni
|
||||
vUBK6zLmF7ElffFBNSuasIVKKGVTn/NECIlPOTZcfEPaJxN9YgcK+v1Uo17IIfvr
|
||||
V6HIf0ECgYEA4YCCKm0lzl4VZF8JtJhW7FnsWU5RCPPFedUmVJa+7gO1DBgqObeT
|
||||
E8OL++YDoEff2m/Sb23isWqe0FYztFYZ2g/lWglznKNRjUunTIKoQ/6RdQvNPDL6
|
||||
oVgr24j55JAg2Ios5HljhNyraWoJpd2jGknk/imu26Y69RkXA7VmJlECgYEA3nsO
|
||||
Pkv2LjBd7VMF0yniO/q9nK/BOi0aZy4x+N7XZ6sXHPOqYdnHhI1tVK37z0+NEe2P
|
||||
owlA2Dg2tqVXV694SYqOmCMYY2uRBkIjEGJ9GK4xirPTGsS/OB34ga1oeo85qfkR
|
||||
z0MzE5UQA3NPfp5Lo1MCxjsACkiiKwi10lW57y0CgYBYj2mPU/JHC7gHBTQAktuA
|
||||
Uwh5QkKc62+gm09EZTdyrk4KA+uBY1EFsARn1zuRVOjbFpNkY5ll5+ObGl+P8UiR
|
||||
1TBTneajm5hJj26So7WFjpJ9jzb472RyvPfsbe0GEHx1zj43NF0bLra63YQQeey2
|
||||
RFMEZkZfyPbajxH0yObnIQKBgQDAINzIB6ltce9rR8s79GufCIY+jbj8mH64pDgb
|
||||
h7XVnPa01ehJ4FxgqBHGkwlmmnhlBxaH4THSh5kYWej3nFzwhWtnDse88+Ol1++X
|
||||
8rW9XpECCxE/iLDpsVguBKa5UH6nvqQWrR2qx4uwrx/zZJhFTyaSMdlzCA6jwz3h
|
||||
io6rcQKBgBknilfMBkHRfaMhcVHWc2aiUsMBSogjY0Wf84mvLW0rDLfwPe5JX3qq
|
||||
VwyXqcFfJ5oZMFmT7+ohcQybhDSdaE4TMkluFSFrYO2HRHzHg0i+K4NjtYhQSxmL
|
||||
25X1Ravg9zXcR6O22jsXVPpRrOm2qA0q5pC9WcVqwYZZjhmzu6A4
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -1 +0,0 @@
|
||||
sw!ft!sC00l
|
||||
@@ -1,36 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIGJTCCBQ2gAwIBAgISA8I9tomI5N82h2iMz35TyPcSMA0GCSqGSIb3DQEBCwUA
|
||||
MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD
|
||||
ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xNzEwMTYxNTAzNThaFw0x
|
||||
ODAxMTQxNTAzNThaMBoxGDAWBgNVBAMTD3NzbC5nZWxhcmVoLnh5ejCCAiIwDQYJ
|
||||
KoZIhvcNAQEBBQADggIPADCCAgoCggIBAKlEE4VdwjkBI/mACJwnAfAGYGk1dimU
|
||||
js+x58JnRvVZfMQQ5f7EGC4ezX2ra9gCngBv+U48P378uMCSxaGAmnyNO2vxWciz
|
||||
v5K5+id2+RMlHkXHlrCKj1TarqUe2W02GdsLiBBXKTBjiC+1dXRztZVXudcbagbz
|
||||
fbjKQIoEPbR+VYBr8WJsL/FpZcXC2Gx2uBO07mtK+WQGo2UpZOE65m0yg74//Eyk
|
||||
L+hyt6PQEvznazSXjpVK+lBS0YwPOK2CQRT7kLUaVCIFf+O6Lg8I1EgEGldc91xh
|
||||
op9H1nBUMIw3xc0FMo5d15f79+yOh91mDWY1F82RidLo8ZaPDgDsy/iL7NrT7plQ
|
||||
qACVSKWqRqvXYIDbF19z9urVqyvnmFlqXtsuf4Iv5JCnnqHQ4852rm9w5sc6mVny
|
||||
ikhmxPABHu3cpBtWDYhyow4FQXi0HAefi8vNw4E1O5lzCcJUgPvj/svsCRn/YgSH
|
||||
Zq2bEGZCsczAiLHGGaIqpsNcnoZOTYN1OU0nqLHY0WGgyx2KzsDWS03+p6Ecm5QF
|
||||
h2DOzO/moF/dsr707wEpgsKrQZ9scvck9BDkc3wCzoH+qAjcFlWdnQk+8/5aldgx
|
||||
BYeOUgE3V4gGCYYggENVLwinH8/c+umpYkhq//SGTff/o5l0u1hp/Gf/WJ5TaZKk
|
||||
nRrATni5hkRtAgMBAAGjggIzMIICLzAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYw
|
||||
FAYIKwYBBQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFFcp
|
||||
eRLK7uObBVrJyJk3t3tV1qA7MB8GA1UdIwQYMBaAFKhKamMEfd265tE5t6ZFZe/z
|
||||
qOyhMG8GCCsGAQUFBwEBBGMwYTAuBggrBgEFBQcwAYYiaHR0cDovL29jc3AuaW50
|
||||
LXgzLmxldHNlbmNyeXB0Lm9yZzAvBggrBgEFBQcwAoYjaHR0cDovL2NlcnQuaW50
|
||||
LXgzLmxldHNlbmNyeXB0Lm9yZy8wPgYDVR0RBDcwNYIPc3NsLmdlbGFyZWgueHl6
|
||||
ghBzc2wxLmdlbGFyZWgueHl6ghBzc2wyLmdlbGFyZWgueHl6MIH+BgNVHSAEgfYw
|
||||
gfMwCAYGZ4EMAQIBMIHmBgsrBgEEAYLfEwEBATCB1jAmBggrBgEFBQcCARYaaHR0
|
||||
cDovL2Nwcy5sZXRzZW5jcnlwdC5vcmcwgasGCCsGAQUFBwICMIGeDIGbVGhpcyBD
|
||||
ZXJ0aWZpY2F0ZSBtYXkgb25seSBiZSByZWxpZWQgdXBvbiBieSBSZWx5aW5nIFBh
|
||||
cnRpZXMgYW5kIG9ubHkgaW4gYWNjb3JkYW5jZSB3aXRoIHRoZSBDZXJ0aWZpY2F0
|
||||
ZSBQb2xpY3kgZm91bmQgYXQgaHR0cHM6Ly9sZXRzZW5jcnlwdC5vcmcvcmVwb3Np
|
||||
dG9yeS8wDQYJKoZIhvcNAQELBQADggEBAB2pZwz/o9x2+/30zrubOTeuVXLVbjDq
|
||||
uqbvmxbUNbCcn2putCiLQ804O1A0bLSLHgj0gKx9eE6bByTBa9k8LeLZB5UCQ9Ns
|
||||
OOZSbzj7d4n+KRg0YrUApH/I3H2C43LK0oRvjdIX/KBEEdsXeML6FwuJnWb84ZEN
|
||||
ZfPVBhrw2aH17EIfm7TcXo8CLjxhuJDA2OOwZVUg7ZMkIvP3EIhsBuyBuIMGHT/7
|
||||
qaeVT7qeSQ3KhOguBnSkmxBwfn/aVZ83p9AvsZX5xuzhg5RCKx3u/qsQMq2Urf8x
|
||||
uDKtmm7AdTHq6DeULVxmHj2386u6Kel1IlZtZNllQj/WW4uDM2EZQ78=
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
Binary file not shown.
@@ -1,28 +0,0 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/
|
||||
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
|
||||
DkRTVCBSb290IENBIFgzMB4XDTE2MDMxNzE2NDA0NloXDTIxMDMxNzE2NDA0Nlow
|
||||
SjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUxldCdzIEVuY3J5cHQxIzAhBgNVBAMT
|
||||
GkxldCdzIEVuY3J5cHQgQXV0aG9yaXR5IFgzMIIBIjANBgkqhkiG9w0BAQEFAAOC
|
||||
AQ8AMIIBCgKCAQEAnNMM8FrlLke3cl03g7NoYzDq1zUmGSXhvb418XCSL7e4S0EF
|
||||
q6meNQhY7LEqxGiHC6PjdeTm86dicbp5gWAf15Gan/PQeGdxyGkOlZHP/uaZ6WA8
|
||||
SMx+yk13EiSdRxta67nsHjcAHJyse6cF6s5K671B5TaYucv9bTyWaN8jKkKQDIZ0
|
||||
Z8h/pZq4UmEUEz9l6YKHy9v6Dlb2honzhT+Xhq+w3Brvaw2VFn3EK6BlspkENnWA
|
||||
a6xK8xuQSXgvopZPKiAlKQTGdMDQMc2PMTiVFrqoM7hD8bEfwzB/onkxEz0tNvjj
|
||||
/PIzark5McWvxI0NHWQWM6r6hCm21AvA2H3DkwIDAQABo4IBfTCCAXkwEgYDVR0T
|
||||
AQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYwfwYIKwYBBQUHAQEEczBxMDIG
|
||||
CCsGAQUFBzABhiZodHRwOi8vaXNyZy50cnVzdGlkLm9jc3AuaWRlbnRydXN0LmNv
|
||||
bTA7BggrBgEFBQcwAoYvaHR0cDovL2FwcHMuaWRlbnRydXN0LmNvbS9yb290cy9k
|
||||
c3Ryb290Y2F4My5wN2MwHwYDVR0jBBgwFoAUxKexpHsscfrb4UuQdf/EFWCFiRAw
|
||||
VAYDVR0gBE0wSzAIBgZngQwBAgEwPwYLKwYBBAGC3xMBAQEwMDAuBggrBgEFBQcC
|
||||
ARYiaHR0cDovL2Nwcy5yb290LXgxLmxldHNlbmNyeXB0Lm9yZzA8BgNVHR8ENTAz
|
||||
MDGgL6AthitodHRwOi8vY3JsLmlkZW50cnVzdC5jb20vRFNUUk9PVENBWDNDUkwu
|
||||
Y3JsMB0GA1UdDgQWBBSoSmpjBH3duubRObemRWXv86jsoTANBgkqhkiG9w0BAQsF
|
||||
AAOCAQEA3TPXEfNjWDjdGBX7CVW+dla5cEilaUcne8IkCJLxWh9KEik3JHRRHGJo
|
||||
uM2VcGfl96S8TihRzZvoroed6ti6WqEBmtzw3Wodatg+VyOeph4EYpr/1wXKtx8/
|
||||
wApIvJSwtmVi4MFU5aMqrSDE6ea73Mj2tcMyo5jMd6jmeWUHK8so/joWUoHOUgwu
|
||||
X4Po1QYz+3dszkDqMp4fklxBwXRsW10KXzPMTZ+sOPAveyxindmjkW8lGy+QsRlG
|
||||
PfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6
|
||||
KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIIFAzCCAusCAQAwbTEYMBYGA1UEAxMPc3NsLmdlbGFyZWgueHl6MRAwDgYDVQQK
|
||||
DAdQcml2YXRlMREwDwYDVQQLDAhJVCBEZXB0LjETMBEGA1UEBwwKV2FzaGluZ3Rv
|
||||
bjEKMAgGA1UECAwBLTELMAkGA1UEBgwCVVMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
|
||||
DwAwggIKAoICAQCpRBOFXcI5ASP5gAicJwHwBmBpNXYplI7PsefCZ0b1WXzEEOX+
|
||||
xBguHs19q2vYAp4Ab/lOPD9+/LjAksWhgJp8jTtr8VnIs7+SufondvkTJR5Fx5aw
|
||||
io9U2q6lHtltNhnbC4gQVykwY4gvtXV0c7WVV7nXG2oG8324ykCKBD20flWAa/Fi
|
||||
bC/xaWXFwthsdrgTtO5rSvlkBqNlKWThOuZtMoO+P/xMpC/ocrej0BL852s0l46V
|
||||
SvpQUtGMDzitgkEU+5C1GlQiBX/jui4PCNRIBBpXXPdcYaKfR9ZwVDCMN8XNBTKO
|
||||
XdeX+/fsjofdZg1mNRfNkYnS6PGWjw4A7Mv4i+za0+6ZUKgAlUilqkar12CA2xdf
|
||||
c/bq1asr55hZal7bLn+CL+SQp56h0OPOdq5vcObHOplZ8opIZsTwAR7t3KQbVg2I
|
||||
cqMOBUF4tBwHn4vLzcOBNTuZcwnCVID74/7L7AkZ/2IEh2atmxBmQrHMwIixxhmi
|
||||
KqbDXJ6GTk2DdTlNJ6ix2NFhoMsdis7A1ktN/qehHJuUBYdgzszv5qBf3bK+9O8B
|
||||
KYLCq0GfbHL3JPQQ5HN8As6B/qgI3BZVnZ0JPvP+WpXYMQWHjlIBN1eIBgmGIIBD
|
||||
VS8Ipx/P3PrpqWJIav/0hk33/6OZdLtYafxn/1ieU2mSpJ0awE54uYZEbQIDAQAB
|
||||
oFEwTwYJKoZIhvcNAQkOMUIwQDA+BgNVHREENzA1gg9zc2wuZ2VsYXJlaC54eXqC
|
||||
EHNzbDEuZ2VsYXJlaC54eXqCEHNzbDIuZ2VsYXJlaC54eXowDQYJKoZIhvcNAQEL
|
||||
BQADggIBAA3xerDVnLk8KAs7ooHWKiQNdM5dUvWgPbMehUxtaZCIA6IraR1qZDfj
|
||||
4+zvumBOPRdbTYbts1xfbdt+T4B+liu+Zkz+zfYJ+pGglDfe9G0oF8fldIfwUzT5
|
||||
v6+VF5wiR6mT3F8pUpLqJd6PMHFlb+WTPKZjYVoBDKQ0G2HLSAfHsocaahPvz9Zg
|
||||
Cz+4FraCk7wlxAG0nzwycQ1NhDpEjQ7Q0UQd23SNWCGc07ZYCfwPLJKCCR0MDhuL
|
||||
J20rZ+PY+7zWXBLULG49mid1uSpp7XmOcIIj0oFvyv0PmaUOWgvm6zr6nBoKALKW
|
||||
Qo0dQhY0ODP19uu/NmcS5T97BW6yWti8c9tWJmeMu9WrO8wMyY8DXID0dgdGo9a7
|
||||
UJo227ZoyqjUHSsrqtP9W8rjok7XRLgxUyRPw1boqAyBnY474v6LUc/VEQNv8mBk
|
||||
u6HJkWD2dWlAaClpzD37PPPOvuQ8BOiaSI6xrL3+VdfD0Q6GE6jaUuhe+KPwv69N
|
||||
v+/ErQQXHP08WeaXMHV9yEOtMmVyRvY+9rVIS9HI6cuXLTcMN8cI8TW5f+0IJ/ll
|
||||
RCY+5Pts++6ajIFC6JwaXBc4mjH8fngHrZByErN3wx0vrPXxs+oXba+ohtnAupNf
|
||||
wA9qIxSKLJtV/xDxHEqyplX0ke7szhbHzOE1ENgPMeNH0/lDmH1F
|
||||
-----END CERTIFICATE REQUEST-----
|
||||
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIJKgIBAAKCAgEAqUQThV3COQEj+YAInCcB8AZgaTV2KZSOz7HnwmdG9Vl8xBDl
|
||||
/sQYLh7Nfatr2AKeAG/5Tjw/fvy4wJLFoYCafI07a/FZyLO/krn6J3b5EyUeRceW
|
||||
sIqPVNqupR7ZbTYZ2wuIEFcpMGOIL7V1dHO1lVe51xtqBvN9uMpAigQ9tH5VgGvx
|
||||
Ymwv8WllxcLYbHa4E7Tua0r5ZAajZSlk4TrmbTKDvj/8TKQv6HK3o9AS/OdrNJeO
|
||||
lUr6UFLRjA84rYJBFPuQtRpUIgV/47ouDwjUSAQaV1z3XGGin0fWcFQwjDfFzQUy
|
||||
jl3Xl/v37I6H3WYNZjUXzZGJ0ujxlo8OAOzL+Ivs2tPumVCoAJVIpapGq9dggNsX
|
||||
X3P26tWrK+eYWWpe2y5/gi/kkKeeodDjznaub3DmxzqZWfKKSGbE8AEe7dykG1YN
|
||||
iHKjDgVBeLQcB5+Ly83DgTU7mXMJwlSA++P+y+wJGf9iBIdmrZsQZkKxzMCIscYZ
|
||||
oiqmw1yehk5Ng3U5TSeosdjRYaDLHYrOwNZLTf6noRyblAWHYM7M7+agX92yvvTv
|
||||
ASmCwqtBn2xy9yT0EORzfALOgf6oCNwWVZ2dCT7z/lqV2DEFh45SATdXiAYJhiCA
|
||||
Q1UvCKcfz9z66aliSGr/9IZN9/+jmXS7WGn8Z/9YnlNpkqSdGsBOeLmGRG0CAwEA
|
||||
AQKCAgAfdzdFyJsta6fbXtC67olurFDJ3hVcP3CY7ZKO0hIf1AXckOOgi6WPFUzP
|
||||
+sjue/YRUL+AqrSHD8XsjpxMnJKbasnMFC7Dn56SUR5OrdA5neHVyPebU/a3KHvk
|
||||
2CpFIhSGYstldj6C703GyK3P+x6bZ5Z1hXQdXLBXZMnAnm82GXIdkHNr/36eGyC/
|
||||
Naxz5VHs3+qeaW6ZCJ7hVGObdw6U6BoTiOOG/9KkHIdE3Y5aE08blLz9xdVojyzD
|
||||
I6U+pAMjOmy5Le7L8EfI9rhPNS35QUIAUZjuRHwtrfYQJaZsuoV7ymaOjqVgbIe3
|
||||
IvvgzXLaOC53mYGMgp8+hNNumpaEDQtUE2HonEJYi8rjhMlhlvh8OWbHCI9yjMRg
|
||||
eMtk3fZ4dtHGFu0XUpZegPFPEMsBmOVELWu9GPs6RNa4U7LsTFBTipUasyKREgdW
|
||||
CbLBu+6+lFe67deUh2150j9PJ9r8SyFUp9UwMMtZirTI6OMxoEylg6gd5Gtvckhz
|
||||
M+VSGX8w/fKRzW7Ipf94TIQlaAkjHI68AB7Qw30uaT9YfbEOP8cMSy9ZBKe+JQ/A
|
||||
EtYsrOjHtARJ7pOWbifnu4zNKg8C4LIDt8sv+en/1/MFXO8+VRVUBmlNzvY8rD1Y
|
||||
5mBftmWdAmFnHCtQH+3VwE331UjpZlYaNTBDe4TwbJeIcTmmQQKCAQEA5JG0/FHa
|
||||
lAvr5Yo8/TI0NqX6bwjn52V6HX5x2Z/wpgQp+WzpSKNCQEWBDsS3X0SfGMJDHFcx
|
||||
X8ysmnLAXcUbBmgnVP2see5cqGQyhHUL/GtfThGAdcs8defkZJspoiFwA1UioJO5
|
||||
JahxBwyxdq6i61ijr1/PjVNWc4wRCsvV/pymmqNKACgiFsW6KB3gq9mcZewK9iZ3
|
||||
nB+H2gQ9PXrC/re9efHO/rUPMuFo3caFZZTTOUbh/Ilno4B//OzXR/mT0ti1YQly
|
||||
5AUkMRwoMUmUGMGZ2IHy2AKEnkk6YvkbTSiTLgsVjgW/MqSjuoeInTwCqRex7Te4
|
||||
3L98/bFGzpG1HQKCAQEAvZRnyWhsUhimOAY0EQ+14bLqEU1D7zFIdEibGVdU4Z49
|
||||
W2/q3CKvbU0gsE5z/L8Y0d+HfKEKsuIvz78SRjds8L1E/V8CReFsyQJW6WO2LNXG
|
||||
eWKMKAJlHuD+s7bOmPssVVj2x05jdoN03tsDKS5rC+DnRYeBnp8uAPdHN5otwDbF
|
||||
FGU1alTGUgTrcboPVf4OhaKh66VxbGliLq35mXW3E90aWtNrByuyJohobfjrpDwd
|
||||
kLK6XbxUdkvIwylk+ZPOL9gI/p1Q38bsSP+w49UxASUvt5CfXaHxhc0qzMrFf2Tm
|
||||
5EYDLx3qsNbqgOf5KzsYwsDsKXUkENsIaRQ7dnU7kQKCAQEA4ndT4WSgs2sUcbwE
|
||||
LcKeZT8S4Qzr6SNsWOi9mSiVYYhiplW41lWcAN5cvus93NC66ecgY2Yo74h1xBnK
|
||||
a54t5q0vu1AUokL/34BXZVIrbBBev5UruIqD/zah3uS13YRP3Z1uz7dODPfV9Wwo
|
||||
MTVbCuAqXksJ9DcMQzQWdqH8B2fi0vjTC1C4ZePHTJQ91UepZHr5aWY3wKKlEeh9
|
||||
XPrTVVlsDPT/aPKwenNIWeSmqz1IA0ouAu+JlkBtj4aCzzeDtbcuD1UzVqWZdGc3
|
||||
k44ZhGXeLtyiZlAoYkSf6wxydoKrQUWON8eN53mlF93OCCw7Xpqxmh5Jtb6s8xfA
|
||||
1k8cKQKCAQEAqONc0oDEfx6WdbKRD+H/FmJdQ6yhqKUu9uj3w0uZwqVF4/+AKzx7
|
||||
K9RaGrbJfZCAe/e2q8CL13DJRzng/czCsHTs0Qui6r44O5pp8uFxmd+YQOsaEUqQ
|
||||
60FlppRk2MRqal4m+sdKtHnH1AEof7dqhdqGLdraDoWgZhvkxhQETgh86f5/54o+
|
||||
YzMezOIEZ4c9SK/psBRjR0FaxlsW0S+dOYTvxZoy7uBuhQVggxgOVPF5JT8T6A2u
|
||||
8PPylmp6Gh0iwlyjJrDfK3v7Y8zluRJj5bFLIS0lzDRJBfoQ9wBtkWBCkXoNvBva
|
||||
yE+t+ciuoWS0WkukGArTZnC6vWHY1175AQKCAQEA2K5DSq6hEcmQGKHBogWW4Emo
|
||||
kz+IyJVwmDPDGhiVWApMODhMVGKbRM4dVVf8CFNYZKyTpbfUdivs0xcALigopjTW
|
||||
bdE/gH7B81yA7hW7UD3oFOMSlu+6xi4GcB43rML1K/6KUAd7a3pVNl3YxywF6dKa
|
||||
e7Tl3Ye0oq1L7haNTgGOd/1C7u72/oKsnoZH7dSGZA/AvhkMCYXWSTGq5iMATUuQ
|
||||
yDh59Twmn9a+bN6bZy/Kt/Lwg+3Xptb9uEkGlwaEvtVzXGa9FfHD4WKt6TavbHY/
|
||||
tI/psRiolGcG5/i8lIQN1USbHdM1v1BPWlr8MDojqXn4n5gUIwtoEEWq4laPvw==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIJJwIBAAKCAgEAjKfEit347Xx0mvjc3cBOhk+fa4Qx/EH/SCz5eMxdBAJe9VfU
|
||||
MKeKjlFHVVtO97Nmv28OPbE5w4LgVtfwjChav76L4uD0GRMsjRGQFXiHV+UtxJ7G
|
||||
MCUUuCgm4IQDQvCJ0oKcJ4YP7UziJOGk8PkIdMjHdzLYaRSZookYXJaSxx/h/OEj
|
||||
W+up7u++Nwh/RUCegLDtdOuFENzovutIzie8sa4lbD3e4QBdayZez2u8pfVMfRiO
|
||||
pYkymCyNNkRwLlOBPZZBCQHfQWjCcGKOJdRq0h5WZ6Rxxza8HA03YoEqASnHJ/ok
|
||||
RQ1Gy0M9osFswyYmaPp8lWMi14aXlMFHbbL+G4p23BhBeiTnDR4wLM/UjATHNVxk
|
||||
KiBnqr2sUHc8dnFqNiUgoJWc2aRL1EToHWOdJ51s/ZLFraPPViOPpCHQG7SetY7a
|
||||
dJFdgQoee4fk9o6Zo9q7izRm70QHHuKGFIjNxs7ZSL6bjYMwKHLK5G75Q3WCqmNd
|
||||
irfsQYjUL/TYNJnazfHV3702YKBcugg08R8q69TNakhfnDgRl5FIMd6Bro3CgA8L
|
||||
bGL4jjoAhx0PohvIlJhghGwQ8xQEfWLmL0pRWUEV4gBIfGxLGQpLqt97choOGdYY
|
||||
GZt+nuzR7KZH175BKNhMI9xcqD6/fb0jNT+GBC2s7DcZSLDODeU0Hf1BXR0CAwEA
|
||||
AQKCAgA7kvtuDeJXRDVnRizWR5N609KkCVPakmF7woDPp09mWVK6+75F9VB8QvTB
|
||||
tHDX/UZxoqoXey8KHi7C2adq1dTKDfzV1Y3N6Q8fmOa8EVbR5aHi+5TZ43rJHUiK
|
||||
I5/2BEd7wBI/s0qfqcbG9EOWRQRN4pSJaiG7MBx6eTK2VJhKeriPERSW5FQPfb/F
|
||||
M3YkcOAxhb6tnOu5Xre91Y36s136q9Xx6Kq0BiGLNq9Fj05RxHnnKjWQ63Fgfs44
|
||||
w/f3xyqgWTmmhQJ4g9SHIVcvsq6j3HGgaEhApnA6OWbR8/9EitttlUczcBIiGZLL
|
||||
kr1sUoZGRIHsDBc/ziP5v3tvfTae9qhqPN0Nnkpl/VLkUieS0iee5f8nCF7NgqMH
|
||||
lPTKzPrsV+6Jq0BwHxh3trKRdfHxocIEQlzmn9MokX7iTWzcirmo3E/rpaCcSlys
|
||||
H5sQtMiN1wtvPCIC4yCPRJf8dkiOK/CjMuEw+bsrO486agVLUOfbDfWWesHQ2Oqm
|
||||
VQSfdLN/WeIzq9rFLp7SywBA0aeNEd4xP55iua+PiTH9nHpcJVk8PFiPwL9Q+Y5p
|
||||
ZFV7CoUGzMJvqbusQca9GX1/kycfDrxrqM7Mb24fmLpmu9LEfQ6cwf04f39KTL1D
|
||||
Js2D+6vwSKmE/21z8JrPUyaizGS3VqRtFGKSYVmk+0f8hZQmyQKCAQEAyBIkBPMe
|
||||
booWLOdo+PpRkwjetbq/zOv3izfd0EG6GL1dy3TO0bzVeEmQ1nRHyOr+23leNxto
|
||||
25uOoZ2yceRiK4i01VKRy4Gc6htegC0/UNpywTxIQEfWQeDZmvHDWpEpZ20GY3ER
|
||||
xBd4xwwZNvyh/j5Jq7hPkDFprCQJ8vouERhQh071HlnE0f8zVfK+t4UdpN6F/5wc
|
||||
kZP8j7C2FRWQn0XjsQeXO2PGZOlNphNYGda4nlaB9b21oYCiFni+TI44fkbEQQCX
|
||||
LervYGy08fTT+Xe3MSGTwo/RwoR4YEubBeGZOCQUjdCl2FT1SVce930RfEQxajH6
|
||||
8Ud7IPI0nvDAQwKCAQEAs/meS7fEisbyoQC9cpXvd6RSNZL+uLrk5Ljb3QnmXdLs
|
||||
D2vfsXKIIfghKwhtStWBBTSyXxqI/EZeTxjPUjC6cW/7ZPPh6P6bCVWPBLystd5N
|
||||
kGtpeJU6tzGOLr2bJKLL9HchntZpbASqE0YIpd3/3cGCjCVYz9FQItI0ghuEaPhP
|
||||
9F8iaqO22jBJIMplvRBNCi7LOBL+dcGHFBi4nVH+K/hYN2Itt1Bxpg+wqzbNhXn0
|
||||
KQahWNZnSTUNCv9CPssYJf5Lkm++c5D1h55MBxOznhP2JQJg6eLG7jZcpQIrVX1Z
|
||||
r76TQSuHWh/xCV6BRaj2RvucYHx7Gv6vWRnLlWLHHwKCAQBr2VuRT30YGVfa3OO5
|
||||
UzamDCIB1KmPzaOjaHopyUSIEYx+IHlclm58aSuqbwRDSmoX5VTkX+Imf7Rjap7G
|
||||
xlYlIYxZciklirkLebV3Yuy+qQMzJ0vLWu4klRC4dZrZN2caWasX79uj2QNCSUNO
|
||||
YODyLKGJ79Dz6a8NHGBAmpw6muDOD8ISmlF+4hLKQhCM3TUdqtaQ85Zy41NCIgAF
|
||||
XZqYQRR8WZssaJyJyToSTFsxko3yzK9ByQIgDTdS5cOvgPrzFzKz152nIv3m/LKN
|
||||
u2yJDf+yfGcqelyYftBlGFx4zyPJH6n0yISeGS4gWtZWkxTZ5+i7VjXv2piFKgsz
|
||||
opQBAoIBAEmXcmDnvdg5TZEEKnMmWAsGCA+cEcgbs+jKpiyWFbqbuqb7pzZ57Kxn
|
||||
N7jO81G8R8uHJsC4qvbtFzckn/Gtty8XaSZ4ixGoumBwudBoDf837WN2aGREMQQj
|
||||
oU3/febXIqrN49N9PRJMPfcvle2s/ykALY983fnsTuZOKeZhthzuHFOCayJL20MQ
|
||||
p3ZfDIbomXfmdnZxXdds0P0otqStmE8Gd5v960+f9zi+BbGc8SD5Ixt7eJJI6WcH
|
||||
6FNs2PuwNCmk9+XjB29eAOf5lID4T2P+KZIsjNBWSJ2zYOKgJnQIk5nHRZNKZ0g0
|
||||
82yvVhDT7BBOZj0V6Yi6R50ZbSOihmUCggEAIfAL588EVaF3lxBnf5L/kCEaeXMO
|
||||
zAVg4DUGgKWBQTyaKplOP01PcmfgPzDBZk0HMBfF+w6R849ufeuO9mIAIP4N4+Q/
|
||||
J7gVKLz6vKZLoPpGXmk/fxCz6d/iH5a4R4KS2IGz/B40DC0vg5wIOgM5VeC5XYxo
|
||||
o8tlDHsL0nmeK6klIZswQgnln1hkgYR8DWdhdtCpOyGoxk+ZObZHYdCShgDzrJHe
|
||||
lNADdNopXdsbmVIOGklgbQDNqAdoZIEMSERevRD4tzi8tVTyNRHH4tzWzvf2Equ7
|
||||
SD9y196c5G8PHQcOX8TG7Q07jojsAcyudjfJ6yITMBVuxiCTFsgn2doyfA==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
|
||||
@@ -0,0 +1,417 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>BlueSocketConnectionListener Class Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Class/BlueSocketConnectionListener" class="dashAnchor"></a>
|
||||
|
||||
<a title="BlueSocketConnectionListener Class Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(99% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
BlueSocketConnectionListener Class Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Classes.html">Other Classes</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/BlueSocketConnectionListener.html">BlueSocketConnectionListener</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/BlueSocketSimpleServer.html">BlueSocketSimpleServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Extensions.html">Other Extensions</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Extensions/UnsafeRawBufferPointer.html">UnsafeRawBufferPointer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Protocols.html">Other Protocols</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>BlueSocketConnectionListener</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">BlueSocketConnectionListener</span><span class="p">:</span> <span class="kt">ParserConnecting</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>The Interface between the StreamingParser class and IBM’s BlueSocket wrapper around socket(2).
|
||||
You hopefully should be able to replace this with any network library/engine.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerCAC0C0ADC6socket_AA15StreamingParserC6parserSo13DispatchQueueC04readK0AK05writeK0tcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(socket:parser:readQueue:writeQueue:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerCAC0C0ADC6socket_AA15StreamingParserC6parserSo13DispatchQueueC04readK0AK05writeK0tcfc">init(socket:parser:readQueue:writeQueue:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>initializer</p>
|
||||
|
||||
<ul>
|
||||
<li>Parameters:
|
||||
|
||||
<ul>
|
||||
<li>socket: Socket object from BlueSocket library wrapping a socket(2)</li>
|
||||
<li>parser: Manager of the CHTTPParser library</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">socket</span><span class="p">:</span> <span class="kt">Socket</span><span class="p">,</span> <span class="nv">parser</span><span class="p">:</span> <span class="kt">StreamingParser</span><span class="p">,</span> <span class="nv">readQueue</span><span class="p">:</span> <span class="kt">DispatchQueue</span><span class="p">,</span> <span class="nv">writeQueue</span><span class="p">:</span> <span class="kt">DispatchQueue</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC6isOpenSbv"></a>
|
||||
<a name="//apple_ref/swift/Property/isOpen" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC6isOpenSbv">isOpen</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Check if socket is still open. Used to decide whether it should be closed/pruned after timeout</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">isOpen</span><span class="p">:</span> <span class="kt">Bool</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC11closeWriteryyF"></a>
|
||||
<a name="//apple_ref/swift/Method/closeWriter()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC11closeWriteryyF">closeWriter()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Called by the parser to let us know that it’s done with this socket</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">closeWriter</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC17responseBeginningyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/responseBeginning()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC17responseBeginningyyF">responseBeginning()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Called by the parser to let us know that a response has started being created</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">responseBeginning</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC16responseCompleteyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/responseComplete()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC16responseCompleteyyF">responseComplete()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Called by the parser to let us know that a response is complete, and we can close after timeout</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">responseComplete</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC7processyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/process()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC7processyyF">process()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Starts reading from the socket and feeding that data to the parser</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">process</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC05queueC5Writey10Foundation4DataVF"></a>
|
||||
<a name="//apple_ref/swift/Method/queueSocketWrite(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC05queueC5Writey10Foundation4DataVF">queueSocketWrite(_:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Called by the parser to give us data to send back out of the socket</p>
|
||||
|
||||
<div class="aside aside-parameter">
|
||||
<p class="aside-title">Parameter</p>
|
||||
Parameter bytes: Data object to be queued to be written to the socket
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">queueSocketWrite</span><span class="p">(</span><span class="n">_</span> <span class="nv">bytes</span><span class="p">:</span> <span class="kt">Data</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC5writey10Foundation4DataVF"></a>
|
||||
<a name="//apple_ref/swift/Method/write(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC5writey10Foundation4DataVF">write(_:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Write data to a socket. Should be called in an <code>async</code> block on the <code>socketWriterQueue</code></p>
|
||||
|
||||
<div class="aside aside-parameter">
|
||||
<p class="aside-title">Parameter</p>
|
||||
Parameter data: data to be written
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">write</span><span class="p">(</span><span class="n">_</span> <span class="nv">data</span><span class="p">:</span><span class="kt">Data</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-08-23)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,326 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>BlueSocketSimpleServer Class Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Class/BlueSocketSimpleServer" class="dashAnchor"></a>
|
||||
|
||||
<a title="BlueSocketSimpleServer Class Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(99% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
BlueSocketSimpleServer Class Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Classes.html">Other Classes</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/BlueSocketConnectionListener.html">BlueSocketConnectionListener</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/BlueSocketSimpleServer.html">BlueSocketSimpleServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Extensions.html">Other Extensions</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Extensions/UnsafeRawBufferPointer.html">UnsafeRawBufferPointer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Protocols.html">Other Protocols</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>BlueSocketSimpleServer</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">BlueSocketSimpleServer</span> <span class="p">:</span> <span class="kt">CurrentConnectionCounting</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>An HTTP server that listens for connections on a TCP socket and spawns Listeners to handle them.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP22BlueSocketSimpleServerC4portSiv"></a>
|
||||
<a name="//apple_ref/swift/Property/port" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP22BlueSocketSimpleServerC4portSiv">port</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The port we’re listening on. Used primarily to query a randomly assigned port during XCTests</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">port</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP22BlueSocketSimpleServerCACycfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP22BlueSocketSimpleServerCACycfc">init()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Undocumented</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">BlueSocketSimpleServer</span> <span class="p">:</span> <span class="kt">CurrentConnectionCounting</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP22BlueSocketSimpleServerC5startySi4port_Si10queueCountSi06acceptI0AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF"></a>
|
||||
<a name="//apple_ref/swift/Method/start(port:queueCount:acceptCount:handler:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP22BlueSocketSimpleServerC5startySi4port_Si10queueCountSi06acceptI0AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF">start(port:queueCount:acceptCount:handler:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Starts the server listening on a given port</p>
|
||||
|
||||
<p><li>Parameters:</p>
|
||||
|
||||
<p><ul>
|
||||
<li>port: TCP port. See listen(2)</li>
|
||||
<li>handler: Function that creates the HTTP Response from the HTTP Request</li>
|
||||
</ul></li>
|
||||
<div class="aside aside-throws">
|
||||
<p class="aside-title">Throws</p>
|
||||
Error (usually a socket error) generated</p>
|
||||
|
||||
<p></div></p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">start</span><span class="p">(</span><span class="nv">port</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">queueCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">acceptCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">handler</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="kt"><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></span><span class="p">)</span> <span class="k">throws</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP22BlueSocketSimpleServerC4stopyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/stop()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP22BlueSocketSimpleServerC4stopyyF">stop()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Stop the server and close the sockets</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">stop</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP22BlueSocketSimpleServerC15connectionCountSiv"></a>
|
||||
<a name="//apple_ref/swift/Property/connectionCount" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP22BlueSocketSimpleServerC15connectionCountSiv">connectionCount</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Count the connections - can be used in XCTests</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">connectionCount</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-08-23)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,301 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPServer Class Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Class/HTTPServer" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPServer Class Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPServer Class Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPServer</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">HTTPServer</span><span class="p">:</span> <span class="kt"><a href="../Protocols/HTTPServing.html">HTTPServing</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>A basic HTTP server. Currently this is implemented using the PoCSocket
|
||||
abstraction, but the intention is to remove this dependency and reimplement
|
||||
the class using transport APIs provided by the Server APIs working group.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPServerCACycfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPServerCACycfc">init()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Create an instance of the server. This needs to be followed with a call to <code><a href="../Classes/HTTPServer.html#/s:4HTTP10HTTPServerC5startySi4port_AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF">start(port:handler:)</a></code></p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPServerC5startySi4port_AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF"></a>
|
||||
<a name="//apple_ref/swift/Method/start(port:handler:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPServerC5startySi4port_AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF">start(port:handler:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Start the HTTP server on the given <code><a href="../Classes/HTTPServer.html#/s:4HTTP10HTTPServerC4portSiv">port</a></code> number, using a <code><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></code> to process incoming requests.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">start</span><span class="p">(</span><span class="nv">port</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">handler</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="kt"><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></span><span class="p">)</span> <span class="k">throws</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPServerC4stopyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/stop()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPServerC4stopyyF">stop()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Stop the server</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">stop</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPServerC4portSiv"></a>
|
||||
<a name="//apple_ref/swift/Property/port" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPServerC4portSiv">port</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The port number the server is listening on</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">port</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPServerC15connectionCountSiv"></a>
|
||||
<a name="//apple_ref/swift/Property/connectionCount" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPServerC15connectionCountSiv">connectionCount</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The number of current connections</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">connectionCount</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,286 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPBodyChunk Enum Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Enum/HTTPBodyChunk" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPBodyChunk Enum Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPBodyChunk Enum Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPBodyChunk</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">HTTPBodyChunk</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>Part or all of the incoming request body</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP13HTTPBodyChunkO5chunkAC8Dispatch0E4DataV4data_yyc18finishedProcessingtcACmF"></a>
|
||||
<a name="//apple_ref/swift/Element/chunk" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP13HTTPBodyChunkO5chunkAC8Dispatch0E4DataV4data_yyc18finishedProcessingtcACmF">chunk</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>A new chunk of the incoming HTTP reqest body data has arrived. <code>finishedProcessing()</code> must be called when
|
||||
that chunk has been processed.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="nf">chunk</span><span class="p">(</span><span class="nv">data</span><span class="p">:</span> <span class="kt">DispatchData</span><span class="p">,</span> <span class="nv">finishedProcessing</span><span class="p">:</span> <span class="p">()</span> <span class="o">-></span> <span class="kt">Void</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP13HTTPBodyChunkO6failedACs5Error_p5error_tcACmF"></a>
|
||||
<a name="//apple_ref/swift/Element/failed" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP13HTTPBodyChunkO6failedACs5Error_p5error_tcACmF">failed</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>An error has occurred whilst streaming the incoming HTTP request data, eg. the connection closed</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="nf">failed</span><span class="p">(</span><span class="nv">error</span><span class="p">:</span> <span class="kt">Error</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP13HTTPBodyChunkO7trailerACSS3key_SS5valuetcACmF"></a>
|
||||
<a name="//apple_ref/swift/Element/trailer" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP13HTTPBodyChunkO7trailerACSS3key_SS5valuetcACmF">trailer</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>A trailer header has arrived during the processing of the incoming HTTP request data.
|
||||
This is currently unimplemented.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="nf">trailer</span><span class="p">(</span><span class="nv">key</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">value</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP13HTTPBodyChunkO3endA2CmF"></a>
|
||||
<a name="//apple_ref/swift/Element/end" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP13HTTPBodyChunkO3endA2CmF">end</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The stream of incoming HTTP request data has completed.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="n">end</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,222 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPBodyProcessing Enum Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Enum/HTTPBodyProcessing" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPBodyProcessing Enum Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPBodyProcessing Enum Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPBodyProcessing</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">HTTPBodyProcessing</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>Indicates whether the body is going to be processed or ignored</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPBodyProcessingO11discardBodyA2CmF"></a>
|
||||
<a name="//apple_ref/swift/Element/discardBody" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPBodyProcessingO11discardBodyA2CmF">discardBody</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Used to discard the body data associated with the incoming HTTP request</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="n">discardBody</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPBodyProcessingO11processBodyACyAA0B5ChunkO_Sbztc7handler_tcACmF"></a>
|
||||
<a name="//apple_ref/swift/Element/processBody" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPBodyProcessingO11processBodyACyAA0B5ChunkO_Sbztc7handler_tcACmF">processBody</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Used to process the body data associated with the imcoming HTTP request using a <code><a href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a></code></p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="nf">processBody</span><span class="p">(</span><span class="nv">handler</span><span class="p">:</span> <span class="kt"><a href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,222 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Result Enum Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Enum/Result" class="dashAnchor"></a>
|
||||
|
||||
<a title="Result Enum Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
Result Enum Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>Result</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">Result</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>The result returned as part of a completion handler</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP6ResultO2okA2CmF"></a>
|
||||
<a name="//apple_ref/swift/Element/ok" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP6ResultO2okA2CmF">ok</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The action was successful</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="n">ok</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP6ResultO5errorACs5Error_pcACmF"></a>
|
||||
<a name="//apple_ref/swift/Element/error" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP6ResultO5errorACs5Error_pcACmF">error</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>An error occurred during the processing of the action</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="nf">error</span><span class="p">(</span><span class="kt">Error</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,205 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>UnsafeRawBufferPointer Extension Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Extension/UnsafeRawBufferPointer" class="dashAnchor"></a>
|
||||
|
||||
<a title="UnsafeRawBufferPointer Extension Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(99% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
UnsafeRawBufferPointer Extension Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Classes.html">Other Classes</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/BlueSocketConnectionListener.html">BlueSocketConnectionListener</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/BlueSocketSimpleServer.html">BlueSocketSimpleServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Extensions.html">Other Extensions</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Extensions/UnsafeRawBufferPointer.html">UnsafeRawBufferPointer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Protocols.html">Other Protocols</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>UnsafeRawBufferPointer</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UnsafeRawBufferPointer</span> <span class="p">:</span> <span class="kt">Collection</span><span class="p">,</span> <span class="kt">RandomAccessCollection</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:s22UnsafeRawBufferPointerV4HTTPE04withA5BytesxxABKcKlF"></a>
|
||||
<a name="//apple_ref/swift/Method/withUnsafeBytes(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:s22UnsafeRawBufferPointerV4HTTPE04withA5BytesxxABKcKlF">withUnsafeBytes(_:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Undocumented</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UnsafeRawBufferPointer</span> <span class="p">:</span> <span class="kt">Collection</span><span class="p">,</span> <span class="kt">RandomAccessCollection</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-08-23)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,223 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTP Headers Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
<script src="js/lunr.min.js" defer></script>
|
||||
<script src="js/typeahead.jquery.js" defer></script>
|
||||
<script src="js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="HTTP Headers Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
HTTP Headers Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTP Headers</h1>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPHeadersV"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPHeaders" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPHeadersV">HTTPHeaders</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Representation of the HTTP headers associated with a <code><a href="Structs/HTTPRequest.html">HTTPRequest</a></code> or <code><a href="Structs/HTTPResponse.html">HTTPResponse</a></code>.
|
||||
Headers are subscriptable using case-insensitive comparison or provide <code>Name</code> constants. eg.</p>
|
||||
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">contentLength</span> <span class="o">=</span> <span class="n">headers</span><span class="p">[</span><span class="s">"content-length"</span><span class="p">]</span>
|
||||
</code></pre>
|
||||
|
||||
<p>or</p>
|
||||
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">contentLength</span> <span class="o">=</span> <span class="n">headers</span><span class="p">[</span><span class="o">.</span><span class="n">contentLength</span><span class="p">]</span>
|
||||
</code></pre>
|
||||
|
||||
<a href="Structs/HTTPHeaders.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPHeaders</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPVersionV"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPVersion" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPVersionV">HTTPVersion</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Version number of the HTTP Protocol</p>
|
||||
|
||||
<a href="Structs/HTTPVersion.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPVersion</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,330 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTP Request Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
<script src="js/lunr.min.js" defer></script>
|
||||
<script src="js/typeahead.jquery.js" defer></script>
|
||||
<script src="js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="HTTP Request Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
HTTP Request Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTP Request</h1>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPRequestV"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPRequest" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPRequestV">HTTPRequest</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>A structure representing the headers from a HTTP request, without the body of the request.</p>
|
||||
|
||||
<a href="Structs/HTTPRequest.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPRequest</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP15HTTPBodyHandlera"></a>
|
||||
<a name="//apple_ref/swift/Alias/HTTPBodyHandler" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Method that takes a chunk of request body and is expected to write to the <code><a href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a></code></p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">HTTPBodyHandler</span> <span class="o">=</span> <span class="p">(</span><span class="kt"><a href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a></span><span class="p">,</span> <span class="k">inout</span> <span class="kt">Bool</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Void</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>HTTPBodyChunk</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p><code>HTTPBodyChunk</code> representing some or all of the incoming request body</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>Bool</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>A boolean flag that can be set to true in order to prevent further processing</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPBodyProcessingO"></a>
|
||||
<a name="//apple_ref/swift/Enum/HTTPBodyProcessing" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPBodyProcessingO">HTTPBodyProcessing</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Indicates whether the body is going to be processed or ignored</p>
|
||||
|
||||
<a href="Enums/HTTPBodyProcessing.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">HTTPBodyProcessing</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP13HTTPBodyChunkO"></a>
|
||||
<a name="//apple_ref/swift/Enum/HTTPBodyChunk" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP13HTTPBodyChunkO">HTTPBodyChunk</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Part or all of the incoming request body</p>
|
||||
|
||||
<a href="Enums/HTTPBodyChunk.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">HTTPBodyChunk</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPMethodV"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPMethod" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPMethodV">HTTPMethod</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>HTTP method structure</p>
|
||||
|
||||
<a href="Structs/HTTPMethod.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPMethod</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,245 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTP Response Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
<script src="js/lunr.min.js" defer></script>
|
||||
<script src="js/typeahead.jquery.js" defer></script>
|
||||
<script src="js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="HTTP Response Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
HTTP Response Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTP Response</h1>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP12HTTPResponseV"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPResponse" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP12HTTPResponseV">HTTPResponse</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>A structure representing the headers for a HTTP response, without the body of the response.</p>
|
||||
|
||||
<a href="Structs/HTTPResponse.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPResponse</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseStatusV"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPResponseStatus" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseStatusV">HTTPResponseStatus</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The response status for the HTTP response</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<a href="https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml">https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml</a> for more information
|
||||
|
||||
</div>
|
||||
|
||||
<a href="Structs/HTTPResponseStatus.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPResponseStatus</span><span class="p">:</span> <span class="kt">Equatable</span><span class="p">,</span> <span class="kt">CustomStringConvertible</span><span class="p">,</span> <span class="kt">ExpressibleByIntegerLiteral</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterP"></a>
|
||||
<a name="//apple_ref/swift/Protocol/HTTPResponseWriter" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterP">HTTPResponseWriter</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>HTTPResponseWriter provides functions to create an HTTP response</p>
|
||||
|
||||
<a href="Protocols/HTTPResponseWriter.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">HTTPResponseWriter</span> <span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,329 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTP Server Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
<script src="js/lunr.min.js" defer></script>
|
||||
<script src="js/typeahead.jquery.js" defer></script>
|
||||
<script src="js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="HTTP Server Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
HTTP Server Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTP Server</h1>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPServerC"></a>
|
||||
<a name="//apple_ref/swift/Class/HTTPServer" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPServerC">HTTPServer</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>A basic HTTP server. Currently this is implemented using the PoCSocket
|
||||
abstraction, but the intention is to remove this dependency and reimplement
|
||||
the class using transport APIs provided by the Server APIs working group.</p>
|
||||
|
||||
<a href="Classes/HTTPServer.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">HTTPServer</span><span class="p">:</span> <span class="kt"><a href="Protocols/HTTPServing.html">HTTPServing</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPServingP"></a>
|
||||
<a name="//apple_ref/swift/Protocol/HTTPServing" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPServingP">HTTPServing</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Definition of an HTTP server.</p>
|
||||
|
||||
<a href="Protocols/HTTPServing.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">HTTPServing</span> <span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPRequestHandlera"></a>
|
||||
<a name="//apple_ref/swift/Alias/HTTPRequestHandler" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Typealias for a closure that handles an incoming HTTP request
|
||||
The following is an example of an echo <code>HTTPRequestHandler</code> that returns the request it receives as a response:</p>
|
||||
<pre class="highlight swift"><code> <span class="kd">func</span> <span class="nf">echo</span><span class="p">(</span><span class="nv">request</span><span class="p">:</span> <span class="kt">HTTPRequest</span><span class="p">,</span> <span class="nv">response</span><span class="p">:</span> <span class="kt">HTTPResponseWriter</span> <span class="p">)</span> <span class="o">-></span> <span class="kt">HTTPBodyProcessing</span> <span class="p">{</span>
|
||||
<span class="n">response</span><span class="o">.</span><span class="nf">writeHeader</span><span class="p">(</span><span class="nv">status</span><span class="p">:</span> <span class="o">.</span><span class="n">ok</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="o">.</span><span class="n">processBody</span> <span class="p">{</span> <span class="p">(</span><span class="n">chunk</span><span class="p">,</span> <span class="n">stop</span><span class="p">)</span> <span class="k">in</span>
|
||||
<span class="k">switch</span> <span class="n">chunk</span> <span class="p">{</span>
|
||||
<span class="k">case</span> <span class="o">.</span><span class="nf">chunk</span><span class="p">(</span><span class="k">let</span> <span class="nv">data</span><span class="p">,</span> <span class="k">let</span> <span class="nv">finishedProcessing</span><span class="p">):</span>
|
||||
<span class="n">response</span><span class="o">.</span><span class="nf">writeBody</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="p">{</span> <span class="n">_</span> <span class="k">in</span>
|
||||
<span class="nf">finishedProcessing</span><span class="p">()</span>
|
||||
<span class="p">}</span>
|
||||
<span class="k">case</span> <span class="o">.</span><span class="nv">end</span><span class="p">:</span>
|
||||
<span class="n">response</span><span class="o">.</span><span class="nf">done</span><span class="p">()</span>
|
||||
<span class="k">default</span><span class="p">:</span>
|
||||
<span class="n">stop</span> <span class="o">=</span> <span class="kc">true</span>
|
||||
<span class="n">response</span><span class="o">.</span><span class="nf">abort</span><span class="p">()</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
|
||||
<p>This then needs to be registered with the server using <code><a href="Classes/HTTPServer.html#/s:4HTTP10HTTPServerC5startySi4port_AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF">HTTPServer.start(port:handler:)</a></code></p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">HTTPRequestHandler</span> <span class="o">=</span> <span class="p">(</span><span class="kt"><a href="Structs/HTTPRequest.html">HTTPRequest</a></span><span class="p">,</span> <span class="kt"><a href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>req</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>the incoming HTTP request.</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>res</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>a writer providing functions to create an HTTP reponse to the request.</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP19HTTPRequestHandlingP"></a>
|
||||
<a name="//apple_ref/swift/Protocol/HTTPRequestHandling" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP19HTTPRequestHandlingP">HTTPRequestHandling</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Class protocol containing a <code>handle()</code> function that implements <code><a href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></code> to respond to incoming HTTP requests.</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<code><a href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></code> for more information
|
||||
|
||||
</div>
|
||||
|
||||
<a href="Protocols/HTTPRequestHandling.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">HTTPRequestHandling</span><span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -1,211 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
|
||||
## Runtime Library Exception to the Apache 2.0 License: ##
|
||||
|
||||
|
||||
As an exception, if you use this Software to compile your source code and
|
||||
portions of this Software are embedded into the binary product as a result,
|
||||
you may redistribute such product without providing attribution as would
|
||||
otherwise be required by Sections 4(a), 4(b) and 4(d) of the License.
|
||||
@@ -0,0 +1,274 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Other Classes Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="Other Classes Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(99% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
Other Classes Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Classes.html">Other Classes</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/BlueSocketConnectionListener.html">BlueSocketConnectionListener</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/BlueSocketSimpleServer.html">BlueSocketSimpleServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Extensions.html">Other Extensions</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Extensions/UnsafeRawBufferPointer.html">UnsafeRawBufferPointer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Protocols.html">Other Protocols</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>Other Classes</h1>
|
||||
<p>The following classes are available globally.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPServerC"></a>
|
||||
<a name="//apple_ref/swift/Class/HTTPServer" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPServerC">HTTPServer</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>A basic HTTP server. Currently this is implemented using the BlueSocket
|
||||
abstraction, but the intention is to remove this dependency and reimplement
|
||||
the class using transport APIs provided by the Server APIs working group.</p>
|
||||
|
||||
<a href="Classes/HTTPServer.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">HTTPServer</span> <span class="p">:</span> <span class="kt"><a href="Protocols/HTTPServing.html">HTTPServing</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC"></a>
|
||||
<a name="//apple_ref/swift/Class/BlueSocketConnectionListener" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC">BlueSocketConnectionListener</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The Interface between the StreamingParser class and IBM’s BlueSocket wrapper around socket(2).
|
||||
You hopefully should be able to replace this with any network library/engine.</p>
|
||||
|
||||
<a href="Classes/BlueSocketConnectionListener.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">BlueSocketConnectionListener</span><span class="p">:</span> <span class="kt">ParserConnecting</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<div class="task-name-container">
|
||||
<a name="/Server"></a>
|
||||
<a name="//apple_ref/swift/Section/Server" class="dashAnchor"></a>
|
||||
<a href="#/Server">
|
||||
<h3 class="section-name">Server</h3>
|
||||
</a>
|
||||
</div>
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP22BlueSocketSimpleServerC"></a>
|
||||
<a name="//apple_ref/swift/Class/BlueSocketSimpleServer" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP22BlueSocketSimpleServerC">BlueSocketSimpleServer</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>An HTTP server that listens for connections on a TCP socket and spawns Listeners to handle them.</p>
|
||||
|
||||
<a href="Classes/BlueSocketSimpleServer.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">BlueSocketSimpleServer</span> <span class="p">:</span> <span class="kt">CurrentConnectionCounting</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-08-23)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,185 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Other Enums Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
<script src="js/lunr.min.js" defer></script>
|
||||
<script src="js/typeahead.jquery.js" defer></script>
|
||||
<script src="js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="Other Enums Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
Other Enums Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>Other Enums</h1>
|
||||
<p>The following enums are available globally.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP6ResultO"></a>
|
||||
<a name="//apple_ref/swift/Enum/Result" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP6ResultO">Result</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The result returned as part of a completion handler</p>
|
||||
|
||||
<a href="Enums/Result.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">Result</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,199 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Other Extensions Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="Other Extensions Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(99% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
Other Extensions Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Classes.html">Other Classes</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/BlueSocketConnectionListener.html">BlueSocketConnectionListener</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/BlueSocketSimpleServer.html">BlueSocketSimpleServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Extensions.html">Other Extensions</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Extensions/UnsafeRawBufferPointer.html">UnsafeRawBufferPointer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Protocols.html">Other Protocols</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>Other Extensions</h1>
|
||||
<p>The following extensions are available globally.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:s22UnsafeRawBufferPointerV"></a>
|
||||
<a name="//apple_ref/swift/Extension/UnsafeRawBufferPointer" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:s22UnsafeRawBufferPointerV">UnsafeRawBufferPointer</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/UnsafeRawBufferPointer.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UnsafeRawBufferPointer</span> <span class="p">:</span> <span class="kt">Collection</span><span class="p">,</span> <span class="kt">RandomAccessCollection</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-08-23)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,200 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Other Protocols Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="Other Protocols Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(99% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
Other Protocols Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Classes.html">Other Classes</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/BlueSocketConnectionListener.html">BlueSocketConnectionListener</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/BlueSocketSimpleServer.html">BlueSocketSimpleServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Extensions.html">Other Extensions</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Extensions/UnsafeRawBufferPointer.html">UnsafeRawBufferPointer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Protocols.html">Other Protocols</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>Other Protocols</h1>
|
||||
<p>The following protocols are available globally.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPServingP"></a>
|
||||
<a name="//apple_ref/swift/Protocol/HTTPServing" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPServingP">HTTPServing</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Definition of an HTTP server.</p>
|
||||
|
||||
<a href="Protocols/HTTPServing.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">HTTPServing</span> <span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-08-23)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -1,35 +0,0 @@
|
||||
// swift-tools-version:4.0
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "SwiftServerHttp",
|
||||
products: [
|
||||
// Products define the executables and libraries produced by a package, and make them visible to other packages.
|
||||
.library(
|
||||
name: "HTTP",
|
||||
targets: ["HTTP"]),
|
||||
],
|
||||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
// .package(url: /* package url */, from: "1.0.0"),
|
||||
// ServerSecurity: common headers, definitions and protocols
|
||||
.package(url: "https://github.com/swift-server/security.git", from: "0.0.0"),
|
||||
// TLSService: implementation of ServerSecurity using OpenSSL and SecureTransport
|
||||
.package(url: "https://github.com/swift-server/TLSService.git", from: "0.20.3"),
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
|
||||
.target(
|
||||
name: "CHTTPParser",
|
||||
dependencies: []),
|
||||
.target(
|
||||
name: "HTTP",
|
||||
dependencies: ["CHTTPParser", "ServerSecurity", "TLSService"]),
|
||||
.testTarget(
|
||||
name: "HTTPTests",
|
||||
dependencies: ["HTTP"]),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,232 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPRequestHandling Protocol Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Protocol/HTTPRequestHandling" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPRequestHandling Protocol Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPRequestHandling Protocol Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPRequestHandling</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">HTTPRequestHandling</span><span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>Class protocol containing a <code>handle()</code> function that implements <code><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></code> to respond to incoming HTTP requests.</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<code><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></code> for more information
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP19HTTPRequestHandlingP6handleAA18HTTPBodyProcessingOAA0B0V7request_AA18HTTPResponseWriter_p8responsetF"></a>
|
||||
<a name="//apple_ref/swift/Method/handle(request:response:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP19HTTPRequestHandlingP6handleAA18HTTPBodyProcessingOAA0B0V7request_AA18HTTPResponseWriter_p8responsetF">handle(request:response:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>handle: function that implements <code><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></code> and is called when a new HTTP request is received by the HTTP server.</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<code><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></code> for more information
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">handle</span><span class="p">(</span><span class="nv">request</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPRequest.html">HTTPRequest</a></span><span class="p">,</span> <span class="nv">response</span><span class="p">:</span> <span class="kt"><a href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>request</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>the incoming HTTP request.</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>response</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>a writer providing functions to create an HTTP response to the request.</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,603 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPResponseWriter Protocol Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Protocol/HTTPResponseWriter" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPResponseWriter Protocol Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPResponseWriter Protocol Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPResponseWriter</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">HTTPResponseWriter</span> <span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>HTTPResponseWriter provides functions to create an HTTP response</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterP11writeHeaderyAA0B6StatusV6status_AA11HTTPHeadersV7headersyAA6ResultOc10completiontF"></a>
|
||||
<a name="//apple_ref/swift/Method/writeHeader(status:headers:completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterP11writeHeaderyAA0B6StatusV6status_AA11HTTPHeadersV7headersyAA6ResultOc10completiontF">writeHeader(status:headers:completion:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Writer function to create the headers for an HTTP response</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">writeHeader</span><span class="p">(</span><span class="nv">status</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a></span><span class="p">,</span> <span class="nv">headers</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPHeaders.html">HTTPHeaders</a></span><span class="p">,</span> <span class="nv">completion</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/Result.html">Result</a></span><span class="p">)</span> <span class="o">-></span> <span class="kt">Void</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>status</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>The status code to include in the HTTP response</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>headers</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>The HTTP headers to include in the HTTP response</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>completion</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>Closure that is called when the HTTP headers have been written to the HTTP respose</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterP12writeTraileryAA11HTTPHeadersV_yAA6ResultOc10completiontF"></a>
|
||||
<a name="//apple_ref/swift/Method/writeTrailer(_:completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterP12writeTraileryAA11HTTPHeadersV_yAA6ResultOc10completiontF">writeTrailer(_:completion:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Writer function to write a trailer header as part of the HTTP response</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">writeTrailer</span><span class="p">(</span><span class="n">_</span> <span class="nv">trailers</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPHeaders.html">HTTPHeaders</a></span><span class="p">,</span> <span class="nv">completion</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/Result.html">Result</a></span><span class="p">)</span> <span class="o">-></span> <span class="kt">Void</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>trailers</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>The trailers to write as part of the HTTP response</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>completion</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>Closure that is called when the trailers has been written to the HTTP response
|
||||
This is not currently implemented</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterP9writeBodyyAA06UnsafebE0_p_yAA6ResultOc10completiontF"></a>
|
||||
<a name="//apple_ref/swift/Method/writeBody(_:completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterP9writeBodyyAA06UnsafebE0_p_yAA6ResultOc10completiontF">writeBody(_:completion:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Writer function to write data to the body of the HTTP response</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">writeBody</span><span class="p">(</span><span class="n">_</span> <span class="nv">data</span><span class="p">:</span> <span class="kt">UnsafeHTTPResponseBody</span><span class="p">,</span> <span class="nv">completion</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/Result.html">Result</a></span><span class="p">)</span> <span class="o">-></span> <span class="kt">Void</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>data</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>The data to write as part of the HTTP response</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>completion</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>Closure that is called when the data has been written to the HTTP response</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterP4doneyyAA6ResultOc10completion_tF"></a>
|
||||
<a name="//apple_ref/swift/Method/done(completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterP4doneyyAA6ResultOc10completion_tF">done(completion:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Writer function to complete the HTTP response</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">done</span><span class="p">(</span><span class="nv">completion</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/Result.html">Result</a></span><span class="p">)</span> <span class="o">-></span> <span class="kt">Void</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>completion</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>Closure that is called when the HTTP response has been completed</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterP5abortyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/abort()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterP5abortyyF">abort()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>abort: Abort the HTTP response</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">abort</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterPAAE11writeHeaderyAA0B6StatusV6status_AA11HTTPHeadersV7headerstF"></a>
|
||||
<a name="//apple_ref/swift/Method/writeHeader(status:headers:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterPAAE11writeHeaderyAA0B6StatusV6status_AA11HTTPHeadersV7headerstF">writeHeader(status:headers:)</a>
|
||||
</code>
|
||||
<span class="declaration-note">
|
||||
Extension method
|
||||
</span>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Convenience function to write the headers for an HTTP response without a completion handler</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<code><a href="../Protocols/HTTPResponseWriter.html#/s:4HTTP18HTTPResponseWriterP11writeHeaderyAA0B6StatusV6status_AA11HTTPHeadersV7headersyAA6ResultOc10completiontF">writeHeader(status:headers:completion:)</a></code>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">writeHeader</span><span class="p">(</span><span class="nv">status</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a></span><span class="p">,</span> <span class="nv">headers</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPHeaders.html">HTTPHeaders</a></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterPAAE11writeHeaderyAA0B6StatusV6status_tF"></a>
|
||||
<a name="//apple_ref/swift/Method/writeHeader(status:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterPAAE11writeHeaderyAA0B6StatusV6status_tF">writeHeader(status:)</a>
|
||||
</code>
|
||||
<span class="declaration-note">
|
||||
Extension method
|
||||
</span>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Convenience function to write a HTTP response with no headers or completion handler</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<code><a href="../Protocols/HTTPResponseWriter.html#/s:4HTTP18HTTPResponseWriterP11writeHeaderyAA0B6StatusV6status_AA11HTTPHeadersV7headersyAA6ResultOc10completiontF">writeHeader(status:headers:completion:)</a></code>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">writeHeader</span><span class="p">(</span><span class="nv">status</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterPAAE12writeTraileryAA11HTTPHeadersVF"></a>
|
||||
<a name="//apple_ref/swift/Method/writeTrailer(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterPAAE12writeTraileryAA11HTTPHeadersVF">writeTrailer(_:)</a>
|
||||
</code>
|
||||
<span class="declaration-note">
|
||||
Extension method
|
||||
</span>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Convenience function to write a trailer header as part of the HTTP response without a completion handler</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<code><a href="../Protocols/HTTPResponseWriter.html#/s:4HTTP18HTTPResponseWriterP12writeTraileryAA11HTTPHeadersV_yAA6ResultOc10completiontF">writeTrailer(_:completion:)</a></code>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">writeTrailer</span><span class="p">(</span><span class="n">_</span> <span class="nv">trailers</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPHeaders.html">HTTPHeaders</a></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterPAAE9writeBodyyAA06UnsafebE0_pF"></a>
|
||||
<a name="//apple_ref/swift/Method/writeBody(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterPAAE9writeBodyyAA06UnsafebE0_pF">writeBody(_:)</a>
|
||||
</code>
|
||||
<span class="declaration-note">
|
||||
Extension method
|
||||
</span>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Convenience function for writing <code>data</code> to the body of the HTTP response without a completion handler.</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
writeBody(_:completion:)
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">writeBody</span><span class="p">(</span><span class="n">_</span> <span class="nv">data</span><span class="p">:</span> <span class="kt">UnsafeHTTPResponseBody</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterPAAE4doneyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/done()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterPAAE4doneyyF">done()</a>
|
||||
</code>
|
||||
<span class="declaration-note">
|
||||
Extension method
|
||||
</span>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Convenience function to complete the HTTP response without a completion handler.</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
done(completion:)
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">done</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,272 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPServing Protocol Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Protocol/HTTPServing" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPServing Protocol Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPServing Protocol Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPServing</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">HTTPServing</span> <span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>Definition of an HTTP server.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPServingP5startySi4port_AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF"></a>
|
||||
<a name="//apple_ref/swift/Method/start(port:handler:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPServingP5startySi4port_AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF">start(port:handler:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Start the HTTP server on the given <code><a href="../Protocols/HTTPServing.html#/s:4HTTP11HTTPServingP4portSiv">port</a></code>, using <code>handler</code> to process incoming requests</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">start</span><span class="p">(</span><span class="nv">port</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span> <span class="nv">handler</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="kt"><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></span><span class="p">)</span> <span class="k">throws</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPServingP4stopyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/stop()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPServingP4stopyyF">stop()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Stop the server</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">stop</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPServingP4portSiv"></a>
|
||||
<a name="//apple_ref/swift/Property/port" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPServingP4portSiv">port</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The port the server is listening on</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">var</span> <span class="nv">port</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPServingP15connectionCountSiv"></a>
|
||||
<a name="//apple_ref/swift/Property/connectionCount" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPServingP15connectionCountSiv">connectionCount</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The number of current connections</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">var</span> <span class="nv">connectionCount</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,236 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>WebAppContaining Protocol Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Protocol/WebAppContaining" class="dashAnchor"></a>
|
||||
|
||||
<a title="WebAppContaining Protocol Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/HTTP/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
WebAppContaining Protocol Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/WebAppContaining.html">WebAppContaining</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP6WebApp">WebApp</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandler">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>WebAppContaining</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">WebAppContaining</span><span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>Class protocol containing the WebApp that responds to the incoming HTTP requests.
|
||||
The following is an example of a WebApp that returns the request as a response:</p>
|
||||
<pre class="highlight swift"><code> <span class="kd">class</span> <span class="kt">EchoWebApp</span><span class="p">:</span> <span class="kt">WebAppContaining</span> <span class="p">{</span>
|
||||
<span class="kd">func</span> <span class="nf">serve</span><span class="p">(</span><span class="nv">req</span><span class="p">:</span> <span class="kt">HTTPRequest</span><span class="p">,</span> <span class="nv">res</span><span class="p">:</span> <span class="kt">HTTPResponseWriter</span> <span class="p">)</span> <span class="o">-></span> <span class="kt">HTTPBodyProcessing</span> <span class="p">{</span>
|
||||
<span class="n">res</span><span class="o">.</span><span class="nf">writeHeader</span><span class="p">(</span><span class="nv">status</span><span class="p">:</span> <span class="o">.</span><span class="n">ok</span><span class="p">,</span> <span class="nv">headers</span><span class="p">:</span> <span class="p">[:])</span>
|
||||
<span class="k">return</span> <span class="o">.</span><span class="n">processBody</span> <span class="p">{</span> <span class="p">(</span><span class="n">chunk</span><span class="p">,</span> <span class="n">stop</span><span class="p">)</span> <span class="k">in</span>
|
||||
<span class="k">switch</span> <span class="n">chunk</span> <span class="p">{</span>
|
||||
<span class="k">case</span> <span class="o">.</span><span class="nf">chunk</span><span class="p">(</span><span class="k">let</span> <span class="nv">data</span><span class="p">,</span> <span class="k">let</span> <span class="nv">finishedProcessing</span><span class="p">):</span>
|
||||
<span class="n">res</span><span class="o">.</span><span class="nf">writeBody</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="p">{</span> <span class="n">_</span> <span class="k">in</span>
|
||||
<span class="nf">finishedProcessing</span><span class="p">()</span>
|
||||
<span class="p">}</span>
|
||||
<span class="k">case</span> <span class="o">.</span><span class="nv">end</span><span class="p">:</span>
|
||||
<span class="n">res</span><span class="o">.</span><span class="nf">done</span><span class="p">()</span>
|
||||
<span class="k">default</span><span class="p">:</span>
|
||||
<span class="n">stop</span> <span class="o">=</span> <span class="kc">true</span>
|
||||
<span class="n">res</span><span class="o">.</span><span class="nf">abort</span><span class="p">()</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:FP4HTTP16WebAppContaining5serveFT3reqVS_11HTTPRequest3resPS_18HTTPResponseWriter__OS_18HTTPBodyProcessing"></a>
|
||||
<a name="//apple_ref/swift/Method/serve(req:res:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FP4HTTP16WebAppContaining5serveFT3reqVS_11HTTPRequest3resPS_18HTTPResponseWriter__OS_18HTTPBodyProcessing">serve(req:res:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>serve: function called when a new HTTP request is received by the HTTP server.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">serve</span><span class="p">(</span><span class="nv">req</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPRequest.html">HTTPRequest</a></span><span class="p">,</span> <span class="nv">res</span><span class="p">:</span> <span class="kt"><a href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a></span> <span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>req</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>the incoming HTTP request.</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>res</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>an writer providing functions to create an HTTP reponse to the request.</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift.org Server APIs Project</a>. All rights reserved. (Last updated: 2017-08-11)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -1,83 +0,0 @@
|
||||
# Swift Server Project HTTP APIs
|
||||
|
||||
:warning: This project is unmaintained experimental legacy code. It has been obsoleted by [SwiftNIO](https://github.com/apple/swift-nio) which contains the recommended HTTP API of the [Swift Server Work Group](https://swift.org/server/).
|
||||
|
||||
It remains here for historical interest only.
|
||||
|
||||
## Getting Started
|
||||
|
||||
|
||||
### Hello World
|
||||
The following code implements a very simple "Hello World!" server:
|
||||
|
||||
```swift
|
||||
import Foundation
|
||||
import HTTP
|
||||
|
||||
func hello(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
response.writeHeader(status: .ok)
|
||||
response.writeBody("Hello, World!")
|
||||
response.done()
|
||||
return .discardBody
|
||||
}
|
||||
|
||||
let server = HTTPServer()
|
||||
try! server.start(port: 8080, handler: hello)
|
||||
|
||||
RunLoop.current.run()
|
||||
```
|
||||
|
||||
The `hello()` function receives a `HTTPRequest` that describes the request and a `HTTPResponseWriter` used to write a response.
|
||||
|
||||
Data that is received as part of the request body is made available to the closure that is returned by the `hello()` function. In the "Hello World!" example the request body is not used, so `.discardBody` is returned.
|
||||
|
||||
### Echo Server
|
||||
The following code implements a very simple Echo server that responds with the contents of the incoming request:
|
||||
|
||||
```swift
|
||||
import Foundation
|
||||
import HTTP
|
||||
|
||||
func echo(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
response.writeHeader(status: .ok)
|
||||
return .processBody { (chunk, stop) in
|
||||
switch chunk {
|
||||
case .chunk(let data, let finishedProcessing):
|
||||
response.writeBody(data) { _ in
|
||||
finishedProcessing()
|
||||
}
|
||||
case .end:
|
||||
response.done()
|
||||
default:
|
||||
stop = true
|
||||
response.abort()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let server = HTTPServer()
|
||||
try! server.start(port: 8080, handler: echo)
|
||||
|
||||
RunLoop.current.run()
|
||||
```
|
||||
As the Echo server needs to process the request body data and return it in the reponse, the `echo()` function returns a `.processBody` closure. This closure is called with `.chunk` when data is available for processing from the request, and `.end` when no more data is available.
|
||||
|
||||
Once any data chunk has been processed, `finishedProcessing()` should be called to signify that it has been handled.
|
||||
|
||||
When the response is complete, `response.done()` should be called.
|
||||
|
||||
## API Documentation
|
||||
Full Jazzy documentation of the API is available here:
|
||||
<https://swift-server.github.io/http/>
|
||||
|
||||
## Contributing
|
||||
|
||||
### Feedback
|
||||
We are actively seeking feedback on this prototype and your comments are extremely valuable. If you have any comments on the API design, the implementation, or any other aspects of this project, please email the [`swift-server-dev`](https://lists.swift.org/mailman/listinfo/swift-server-dev) mailing list.
|
||||
|
||||
### Writing Code
|
||||
We also welcome code contributions. If you are developing on macOS, you may want to work within Xcode. This project uses the [Swift Package Manager](https://swift.org/package-manager/). To work on this project within Xcode you can run the Swift Package Manager command `swift package generate-xcodeproj` to generate an `.xcodeproj` to work on within Xcode.
|
||||
|
||||
## Acknowledgements
|
||||
This project is based on an inital proposal from @weissi on the swift-server-dev mailing list:
|
||||
<https://lists.swift.org/pipermail/swift-server-dev/Week-of-Mon-20170403/000422.html>
|
||||
@@ -1,68 +0,0 @@
|
||||
# Authors ordered by first contribution.
|
||||
Ryan Dahl <ry@tinyclouds.org>
|
||||
Jeremy Hinegardner <jeremy@hinegardner.org>
|
||||
Sergey Shepelev <temotor@gmail.com>
|
||||
Joe Damato <ice799@gmail.com>
|
||||
tomika <tomika_nospam@freemail.hu>
|
||||
Phoenix Sol <phoenix@burninglabs.com>
|
||||
Cliff Frey <cliff@meraki.com>
|
||||
Ewen Cheslack-Postava <ewencp@cs.stanford.edu>
|
||||
Santiago Gala <sgala@apache.org>
|
||||
Tim Becker <tim.becker@syngenio.de>
|
||||
Jeff Terrace <jterrace@gmail.com>
|
||||
Ben Noordhuis <info@bnoordhuis.nl>
|
||||
Nathan Rajlich <nathan@tootallnate.net>
|
||||
Mark Nottingham <mnot@mnot.net>
|
||||
Aman Gupta <aman@tmm1.net>
|
||||
Tim Becker <tim.becker@kuriositaet.de>
|
||||
Sean Cunningham <sean.cunningham@mandiant.com>
|
||||
Peter Griess <pg@std.in>
|
||||
Salman Haq <salman.haq@asti-usa.com>
|
||||
Cliff Frey <clifffrey@gmail.com>
|
||||
Jon Kolb <jon@b0g.us>
|
||||
Fouad Mardini <f.mardini@gmail.com>
|
||||
Paul Querna <pquerna@apache.org>
|
||||
Felix Geisendörfer <felix@debuggable.com>
|
||||
koichik <koichik@improvement.jp>
|
||||
Andre Caron <andre.l.caron@gmail.com>
|
||||
Ivo Raisr <ivosh@ivosh.net>
|
||||
James McLaughlin <jamie@lacewing-project.org>
|
||||
David Gwynne <loki@animata.net>
|
||||
Thomas LE ROUX <thomas@november-eleven.fr>
|
||||
Randy Rizun <rrizun@ortivawireless.com>
|
||||
Andre Louis Caron <andre.louis.caron@usherbrooke.ca>
|
||||
Simon Zimmermann <simonz05@gmail.com>
|
||||
Erik Dubbelboer <erik@dubbelboer.com>
|
||||
Martell Malone <martellmalone@gmail.com>
|
||||
Bertrand Paquet <bpaquet@octo.com>
|
||||
BogDan Vatra <bogdan@kde.org>
|
||||
Peter Faiman <peter@thepicard.org>
|
||||
Corey Richardson <corey@octayn.net>
|
||||
Tóth Tamás <tomika_nospam@freemail.hu>
|
||||
Cam Swords <cam.swords@gmail.com>
|
||||
Chris Dickinson <christopher.s.dickinson@gmail.com>
|
||||
Uli Köhler <ukoehler@btronik.de>
|
||||
Charlie Somerville <charlie@charliesomerville.com>
|
||||
Patrik Stutz <patrik.stutz@gmail.com>
|
||||
Fedor Indutny <fedor.indutny@gmail.com>
|
||||
runner <runner.mei@gmail.com>
|
||||
Alexis Campailla <alexis@janeasystems.com>
|
||||
David Wragg <david@wragg.org>
|
||||
Vinnie Falco <vinnie.falco@gmail.com>
|
||||
Alex Butum <alexbutum@linux.com>
|
||||
Rex Feng <rexfeng@gmail.com>
|
||||
Alex Kocharin <alex@kocharin.ru>
|
||||
Mark Koopman <markmontymark@yahoo.com>
|
||||
Helge Heß <me@helgehess.eu>
|
||||
Alexis La Goutte <alexis.lagoutte@gmail.com>
|
||||
George Miroshnykov <george.miroshnykov@gmail.com>
|
||||
Maciej Małecki <me@mmalecki.com>
|
||||
Marc O'Morain <github.com@marcomorain.com>
|
||||
Jeff Pinner <jpinner@twitter.com>
|
||||
Timothy J Fontaine <tjfontaine@gmail.com>
|
||||
Akagi201 <akagi201@gmail.com>
|
||||
Romain Giraud <giraud.romain@gmail.com>
|
||||
Jay Satiro <raysatiro@yahoo.com>
|
||||
Arne Steen <Arne.Steen@gmx.de>
|
||||
Kjell Schubert <kjell.schubert@gmail.com>
|
||||
Olivier Mengué <dolmen@cpan.org>
|
||||
@@ -1,23 +0,0 @@
|
||||
http_parser.c is based on src/http/ngx_http_parse.c from NGINX copyright
|
||||
Igor Sysoev.
|
||||
|
||||
Additional changes are licensed under the same terms as NGINX and
|
||||
copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,362 +0,0 @@
|
||||
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
#ifndef http_parser_h
|
||||
#define http_parser_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Also update SONAME in the Makefile whenever you change these. */
|
||||
#define HTTP_PARSER_VERSION_MAJOR 2
|
||||
#define HTTP_PARSER_VERSION_MINOR 7
|
||||
#define HTTP_PARSER_VERSION_PATCH 1
|
||||
|
||||
#include <sys/types.h>
|
||||
#if defined(_WIN32) && !defined(__MINGW32__) && \
|
||||
(!defined(_MSC_VER) || _MSC_VER<1600) && !defined(__WINE__)
|
||||
#include <BaseTsd.h>
|
||||
#include <stddef.h>
|
||||
typedef __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
/* Compile with -DHTTP_PARSER_STRICT=0 to make less checks, but run
|
||||
* faster
|
||||
*/
|
||||
#ifndef HTTP_PARSER_STRICT
|
||||
# define HTTP_PARSER_STRICT 1
|
||||
#endif
|
||||
|
||||
/* Maximium header size allowed. If the macro is not defined
|
||||
* before including this header then the default is used. To
|
||||
* change the maximum header size, define the macro in the build
|
||||
* environment (e.g. -DHTTP_MAX_HEADER_SIZE=<value>). To remove
|
||||
* the effective limit on the size of the header, define the macro
|
||||
* to a very large number (e.g. -DHTTP_MAX_HEADER_SIZE=0x7fffffff)
|
||||
*/
|
||||
#ifndef HTTP_MAX_HEADER_SIZE
|
||||
# define HTTP_MAX_HEADER_SIZE (80*1024)
|
||||
#endif
|
||||
|
||||
typedef struct http_parser http_parser;
|
||||
typedef struct http_parser_settings http_parser_settings;
|
||||
|
||||
|
||||
/* Callbacks should return non-zero to indicate an error. The parser will
|
||||
* then halt execution.
|
||||
*
|
||||
* The one exception is on_headers_complete. In a HTTP_RESPONSE parser
|
||||
* returning '1' from on_headers_complete will tell the parser that it
|
||||
* should not expect a body. This is used when receiving a response to a
|
||||
* HEAD request which may contain 'Content-Length' or 'Transfer-Encoding:
|
||||
* chunked' headers that indicate the presence of a body.
|
||||
*
|
||||
* Returning `2` from on_headers_complete will tell parser that it should not
|
||||
* expect neither a body nor any futher responses on this connection. This is
|
||||
* useful for handling responses to a CONNECT request which may not contain
|
||||
* `Upgrade` or `Connection: upgrade` headers.
|
||||
*
|
||||
* http_data_cb does not return data chunks. It will be called arbitrarily
|
||||
* many times for each string. E.G. you might get 10 callbacks for "on_url"
|
||||
* each providing just a few characters more data.
|
||||
*/
|
||||
typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);
|
||||
typedef int (*http_cb) (http_parser*);
|
||||
|
||||
|
||||
/* Request Methods */
|
||||
#define HTTP_METHOD_MAP(XX) \
|
||||
XX(0, DELETE, DELETE) \
|
||||
XX(1, GET, GET) \
|
||||
XX(2, HEAD, HEAD) \
|
||||
XX(3, POST, POST) \
|
||||
XX(4, PUT, PUT) \
|
||||
/* pathological */ \
|
||||
XX(5, CONNECT, CONNECT) \
|
||||
XX(6, OPTIONS, OPTIONS) \
|
||||
XX(7, TRACE, TRACE) \
|
||||
/* WebDAV */ \
|
||||
XX(8, COPY, COPY) \
|
||||
XX(9, LOCK, LOCK) \
|
||||
XX(10, MKCOL, MKCOL) \
|
||||
XX(11, MOVE, MOVE) \
|
||||
XX(12, PROPFIND, PROPFIND) \
|
||||
XX(13, PROPPATCH, PROPPATCH) \
|
||||
XX(14, SEARCH, SEARCH) \
|
||||
XX(15, UNLOCK, UNLOCK) \
|
||||
XX(16, BIND, BIND) \
|
||||
XX(17, REBIND, REBIND) \
|
||||
XX(18, UNBIND, UNBIND) \
|
||||
XX(19, ACL, ACL) \
|
||||
/* subversion */ \
|
||||
XX(20, REPORT, REPORT) \
|
||||
XX(21, MKACTIVITY, MKACTIVITY) \
|
||||
XX(22, CHECKOUT, CHECKOUT) \
|
||||
XX(23, MERGE, MERGE) \
|
||||
/* upnp */ \
|
||||
XX(24, MSEARCH, M-SEARCH) \
|
||||
XX(25, NOTIFY, NOTIFY) \
|
||||
XX(26, SUBSCRIBE, SUBSCRIBE) \
|
||||
XX(27, UNSUBSCRIBE, UNSUBSCRIBE) \
|
||||
/* RFC-5789 */ \
|
||||
XX(28, PATCH, PATCH) \
|
||||
XX(29, PURGE, PURGE) \
|
||||
/* CalDAV */ \
|
||||
XX(30, MKCALENDAR, MKCALENDAR) \
|
||||
/* RFC-2068, section 19.6.1.2 */ \
|
||||
XX(31, LINK, LINK) \
|
||||
XX(32, UNLINK, UNLINK) \
|
||||
|
||||
enum http_method
|
||||
{
|
||||
#define XX(num, name, string) HTTP_##name = num,
|
||||
HTTP_METHOD_MAP(XX)
|
||||
#undef XX
|
||||
};
|
||||
|
||||
|
||||
enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
|
||||
|
||||
|
||||
/* Flag values for http_parser.flags field */
|
||||
enum flags
|
||||
{ F_CHUNKED = 1 << 0
|
||||
, F_CONNECTION_KEEP_ALIVE = 1 << 1
|
||||
, F_CONNECTION_CLOSE = 1 << 2
|
||||
, F_CONNECTION_UPGRADE = 1 << 3
|
||||
, F_TRAILING = 1 << 4
|
||||
, F_UPGRADE = 1 << 5
|
||||
, F_SKIPBODY = 1 << 6
|
||||
, F_CONTENTLENGTH = 1 << 7
|
||||
};
|
||||
|
||||
|
||||
/* Map for errno-related constants
|
||||
*
|
||||
* The provided argument should be a macro that takes 2 arguments.
|
||||
*/
|
||||
#define HTTP_ERRNO_MAP(XX) \
|
||||
/* No error */ \
|
||||
XX(OK, "success") \
|
||||
\
|
||||
/* Callback-related errors */ \
|
||||
XX(CB_message_begin, "the on_message_begin callback failed") \
|
||||
XX(CB_url, "the on_url callback failed") \
|
||||
XX(CB_header_field, "the on_header_field callback failed") \
|
||||
XX(CB_header_value, "the on_header_value callback failed") \
|
||||
XX(CB_headers_complete, "the on_headers_complete callback failed") \
|
||||
XX(CB_body, "the on_body callback failed") \
|
||||
XX(CB_message_complete, "the on_message_complete callback failed") \
|
||||
XX(CB_status, "the on_status callback failed") \
|
||||
XX(CB_chunk_header, "the on_chunk_header callback failed") \
|
||||
XX(CB_chunk_complete, "the on_chunk_complete callback failed") \
|
||||
\
|
||||
/* Parsing-related errors */ \
|
||||
XX(INVALID_EOF_STATE, "stream ended at an unexpected time") \
|
||||
XX(HEADER_OVERFLOW, \
|
||||
"too many header bytes seen; overflow detected") \
|
||||
XX(CLOSED_CONNECTION, \
|
||||
"data received after completed connection: close message") \
|
||||
XX(INVALID_VERSION, "invalid HTTP version") \
|
||||
XX(INVALID_STATUS, "invalid HTTP status code") \
|
||||
XX(INVALID_METHOD, "invalid HTTP method") \
|
||||
XX(INVALID_URL, "invalid URL") \
|
||||
XX(INVALID_HOST, "invalid host") \
|
||||
XX(INVALID_PORT, "invalid port") \
|
||||
XX(INVALID_PATH, "invalid path") \
|
||||
XX(INVALID_QUERY_STRING, "invalid query string") \
|
||||
XX(INVALID_FRAGMENT, "invalid fragment") \
|
||||
XX(LF_EXPECTED, "LF character expected") \
|
||||
XX(INVALID_HEADER_TOKEN, "invalid character in header") \
|
||||
XX(INVALID_CONTENT_LENGTH, \
|
||||
"invalid character in content-length header") \
|
||||
XX(UNEXPECTED_CONTENT_LENGTH, \
|
||||
"unexpected content-length header") \
|
||||
XX(INVALID_CHUNK_SIZE, \
|
||||
"invalid character in chunk size header") \
|
||||
XX(INVALID_CONSTANT, "invalid constant string") \
|
||||
XX(INVALID_INTERNAL_STATE, "encountered unexpected internal state")\
|
||||
XX(STRICT, "strict mode assertion failed") \
|
||||
XX(PAUSED, "parser is paused") \
|
||||
XX(UNKNOWN, "an unknown error occurred")
|
||||
|
||||
|
||||
/* Define HPE_* values for each errno value above */
|
||||
#define HTTP_ERRNO_GEN(n, s) HPE_##n,
|
||||
enum http_errno {
|
||||
HTTP_ERRNO_MAP(HTTP_ERRNO_GEN)
|
||||
};
|
||||
#undef HTTP_ERRNO_GEN
|
||||
|
||||
|
||||
/* Get an http_errno value from an http_parser */
|
||||
#define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno)
|
||||
|
||||
|
||||
struct http_parser {
|
||||
/** PRIVATE **/
|
||||
unsigned int type : 2; /* enum http_parser_type */
|
||||
unsigned int flags : 8; /* F_* values from 'flags' enum; semi-public */
|
||||
unsigned int state : 7; /* enum state from http_parser.c */
|
||||
unsigned int header_state : 7; /* enum header_state from http_parser.c */
|
||||
unsigned int index : 7; /* index into current matcher */
|
||||
unsigned int lenient_http_headers : 1;
|
||||
|
||||
uint32_t nread; /* # bytes read in various scenarios */
|
||||
uint64_t content_length; /* # bytes in body (0 if no Content-Length header) */
|
||||
|
||||
/** READ-ONLY **/
|
||||
unsigned short http_major;
|
||||
unsigned short http_minor;
|
||||
unsigned int status_code : 16; /* responses only */
|
||||
unsigned int method : 8; /* requests only */
|
||||
unsigned int http_errno : 7;
|
||||
|
||||
/* 1 = Upgrade header was present and the parser has exited because of that.
|
||||
* 0 = No upgrade header present.
|
||||
* Should be checked when http_parser_execute() returns in addition to
|
||||
* error checking.
|
||||
*/
|
||||
unsigned int upgrade : 1;
|
||||
|
||||
/** PUBLIC **/
|
||||
void *data; /* A pointer to get hook to the "connection" or "socket" object */
|
||||
};
|
||||
|
||||
|
||||
struct http_parser_settings {
|
||||
http_cb on_message_begin;
|
||||
http_data_cb on_url;
|
||||
http_data_cb on_status;
|
||||
http_data_cb on_header_field;
|
||||
http_data_cb on_header_value;
|
||||
http_cb on_headers_complete;
|
||||
http_data_cb on_body;
|
||||
http_cb on_message_complete;
|
||||
/* When on_chunk_header is called, the current chunk length is stored
|
||||
* in parser->content_length.
|
||||
*/
|
||||
http_cb on_chunk_header;
|
||||
http_cb on_chunk_complete;
|
||||
};
|
||||
|
||||
|
||||
enum http_parser_url_fields
|
||||
{ UF_SCHEMA = 0
|
||||
, UF_HOST = 1
|
||||
, UF_PORT = 2
|
||||
, UF_PATH = 3
|
||||
, UF_QUERY = 4
|
||||
, UF_FRAGMENT = 5
|
||||
, UF_USERINFO = 6
|
||||
, UF_MAX = 7
|
||||
};
|
||||
|
||||
|
||||
/* Result structure for http_parser_parse_url().
|
||||
*
|
||||
* Callers should index into field_data[] with UF_* values iff field_set
|
||||
* has the relevant (1 << UF_*) bit set. As a courtesy to clients (and
|
||||
* because we probably have padding left over), we convert any port to
|
||||
* a uint16_t.
|
||||
*/
|
||||
struct http_parser_url {
|
||||
uint16_t field_set; /* Bitmask of (1 << UF_*) values */
|
||||
uint16_t port; /* Converted UF_PORT string */
|
||||
|
||||
struct {
|
||||
uint16_t off; /* Offset into buffer in which field starts */
|
||||
uint16_t len; /* Length of run in buffer */
|
||||
} field_data[UF_MAX];
|
||||
};
|
||||
|
||||
|
||||
/* Returns the library version. Bits 16-23 contain the major version number,
|
||||
* bits 8-15 the minor version number and bits 0-7 the patch level.
|
||||
* Usage example:
|
||||
*
|
||||
* unsigned long version = http_parser_version();
|
||||
* unsigned major = (version >> 16) & 255;
|
||||
* unsigned minor = (version >> 8) & 255;
|
||||
* unsigned patch = version & 255;
|
||||
* printf("http_parser v%u.%u.%u\n", major, minor, patch);
|
||||
*/
|
||||
unsigned long http_parser_version(void);
|
||||
|
||||
void http_parser_init(http_parser *parser, enum http_parser_type type);
|
||||
|
||||
|
||||
/* Initialize http_parser_settings members to 0
|
||||
*/
|
||||
void http_parser_settings_init(http_parser_settings *settings);
|
||||
|
||||
|
||||
/* Executes the parser. Returns number of parsed bytes. Sets
|
||||
* `parser->http_errno` on error. */
|
||||
size_t http_parser_execute(http_parser *parser,
|
||||
const http_parser_settings *settings,
|
||||
const char *data,
|
||||
size_t len);
|
||||
|
||||
|
||||
/* If http_should_keep_alive() in the on_headers_complete or
|
||||
* on_message_complete callback returns 0, then this should be
|
||||
* the last message on the connection.
|
||||
* If you are the server, respond with the "Connection: close" header.
|
||||
* If you are the client, close the connection.
|
||||
*/
|
||||
int http_should_keep_alive(const http_parser *parser);
|
||||
|
||||
/* Returns a string version of the HTTP method. */
|
||||
const char *http_method_str(enum http_method m);
|
||||
|
||||
/* Return a string name of the given error */
|
||||
const char *http_errno_name(enum http_errno err);
|
||||
|
||||
/* Return a string description of the given error */
|
||||
const char *http_errno_description(enum http_errno err);
|
||||
|
||||
/* Initialize all http_parser_url members to 0 */
|
||||
void http_parser_url_init(struct http_parser_url *u);
|
||||
|
||||
/* Parse a URL; return nonzero on failure */
|
||||
int http_parser_parse_url(const char *buf, size_t buflen,
|
||||
int is_connect,
|
||||
struct http_parser_url *u);
|
||||
|
||||
/* Pause or un-pause the parser; a nonzero value pauses */
|
||||
void http_parser_pause(http_parser *parser, int paused);
|
||||
|
||||
/* Checks if this is the final chunk of the body. */
|
||||
int http_body_is_final(const http_parser *parser);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,54 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Typealias for a closure that handles an incoming HTTP request
|
||||
/// The following is an example of an echo `HTTPRequestHandler` that returns the request it receives as a response:
|
||||
/// ```swift
|
||||
/// func echo(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
/// response.writeHeader(status: .ok)
|
||||
/// return .processBody { (chunk, stop) in
|
||||
/// switch chunk {
|
||||
/// case .chunk(let data, let finishedProcessing):
|
||||
/// response.writeBody(data) { _ in
|
||||
/// finishedProcessing()
|
||||
/// }
|
||||
/// case .end:
|
||||
/// response.done()
|
||||
/// default:
|
||||
/// stop = true
|
||||
/// response.abort()
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
/// This then needs to be registered with the server using `HTTPServer.start(port:handler:)`
|
||||
/// - Parameter req: the incoming HTTP request.
|
||||
/// - Parameter res: a writer providing functions to create an HTTP reponse to the request.
|
||||
/// - Returns HTTPBodyProcessing: a enum that either discards the request data, or provides a closure to process it.
|
||||
public typealias HTTPRequestHandler = (HTTPRequest, HTTPResponseWriter) -> HTTPBodyProcessing
|
||||
|
||||
/// Class protocol containing a `handle()` function that implements `HTTPRequestHandler` to respond to incoming HTTP requests.
|
||||
/// - See: `HTTPRequestHandler` for more information
|
||||
public protocol HTTPRequestHandling: class {
|
||||
/// handle: function that implements `HTTPRequestHandler` and is called when a new HTTP request is received by the HTTP server.
|
||||
/// - Parameter request: the incoming HTTP request.
|
||||
/// - Parameter response: a writer providing functions to create an HTTP response to the request.
|
||||
/// - Returns HTTPBodyProcessing: a enum that either discards the request data, or provides a closure to process it.
|
||||
/// - See: `HTTPRequestHandler` for more information
|
||||
func handle(request: HTTPRequest, response: HTTPResponseWriter) -> HTTPBodyProcessing
|
||||
}
|
||||
|
||||
/// The result returned as part of a completion handler
|
||||
public enum Result {
|
||||
/// The action was successful
|
||||
case ok
|
||||
/// An error occurred during the processing of the action
|
||||
case error(Error)
|
||||
}
|
||||
@@ -1,543 +0,0 @@
|
||||
/// Representation of the HTTP headers associated with a `HTTPRequest` or `HTTPResponse`.
|
||||
/// Headers are subscriptable using case-insensitive comparison or provide `Name` constants. eg.
|
||||
/// ```swift
|
||||
/// let contentLength = headers["content-length"]
|
||||
/// ```
|
||||
/// or
|
||||
/// ```swift
|
||||
/// let contentLength = headers[.contentLength]
|
||||
/// ```
|
||||
public struct HTTPHeaders {
|
||||
var original: [(name: Name, value: String)]?
|
||||
var storage: [Name: [String]] {
|
||||
didSet { original = nil }
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public subscript(name: Name) -> String? {
|
||||
get {
|
||||
guard let value = storage[name] else { return nil }
|
||||
switch name {
|
||||
case Name.setCookie: // Exception, see note in [RFC7230, section 3.2.2]
|
||||
return value.isEmpty ? nil : value[0]
|
||||
default:
|
||||
return value.joined(separator: ",")
|
||||
}
|
||||
}
|
||||
set {
|
||||
storage[name] = newValue.map { [$0] }
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public subscript(valuesFor name: Name) -> [String] {
|
||||
get { return storage[name] ?? [] }
|
||||
set { storage[name] = newValue.isEmpty ? nil : newValue }
|
||||
}
|
||||
}
|
||||
|
||||
extension HTTPHeaders: ExpressibleByDictionaryLiteral {
|
||||
/// Creates HTTP headers.
|
||||
public init(dictionaryLiteral: (Name, String)...) {
|
||||
storage = [:]
|
||||
for (name, value) in dictionaryLiteral {
|
||||
#if swift(>=4.0)
|
||||
storage[name, default: []].append(value)
|
||||
#else
|
||||
if storage[name] == nil {
|
||||
storage[name] = [value]
|
||||
} else {
|
||||
storage[name]!.append(value)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
original = dictionaryLiteral
|
||||
}
|
||||
}
|
||||
|
||||
extension HTTPHeaders {
|
||||
// Used instead of HTTPHeaders to save CPU on dictionary construction
|
||||
/// :nodoc:
|
||||
public struct Literal: ExpressibleByDictionaryLiteral {
|
||||
let fields: [(name: Name, value: String)]
|
||||
|
||||
public init(dictionaryLiteral: (Name, String)...) {
|
||||
fields = dictionaryLiteral
|
||||
}
|
||||
}
|
||||
|
||||
/// Appends a header to the headers
|
||||
public mutating func append(_ literal: HTTPHeaders.Literal) {
|
||||
for (name, value) in literal.fields {
|
||||
#if swift(>=4.0)
|
||||
storage[name, default: []].append(value)
|
||||
#else
|
||||
if storage[name] == nil {
|
||||
storage[name] = [value]
|
||||
} else {
|
||||
storage[name]!.append(value)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// Replaces a header in the headers
|
||||
public mutating func replace(_ literal: HTTPHeaders.Literal) {
|
||||
for (name, _) in literal.fields {
|
||||
storage[name] = []
|
||||
}
|
||||
for (name, value) in literal.fields {
|
||||
storage[name]!.append(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension HTTPHeaders: Sequence {
|
||||
/// :nodoc:
|
||||
public func makeIterator() -> AnyIterator<(name: Name, value: String)> {
|
||||
if let original = original {
|
||||
return AnyIterator(original.makeIterator())
|
||||
} else {
|
||||
return AnyIterator(StorageIterator(storage.makeIterator()))
|
||||
}
|
||||
}
|
||||
|
||||
struct StorageIterator: IteratorProtocol {
|
||||
var headers: DictionaryIterator<Name, [String]>
|
||||
var header: (name: Name, values: IndexingIterator<[String]>)?
|
||||
|
||||
init(_ iterator: DictionaryIterator<Name, [String]>) {
|
||||
headers = iterator
|
||||
header = headers.next().map { (name: $0.key, values: $0.value.makeIterator()) }
|
||||
}
|
||||
|
||||
mutating func next() -> (name: Name, value: String)? {
|
||||
while header != nil {
|
||||
if let value = header!.values.next() {
|
||||
return (name: header!.name, value: value)
|
||||
} else {
|
||||
header = headers.next().map { (name: $0.key, values: $0.value.makeIterator()) }
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// HTTPHeaders structure.
|
||||
extension HTTPHeaders {
|
||||
/// Type used for the name of a HTTP header in the `HTTPHeaders` storage.
|
||||
public struct Name: Hashable, ExpressibleByStringLiteral, CustomStringConvertible {
|
||||
let original: String
|
||||
let lowercased: String
|
||||
public let hashValue: Int
|
||||
|
||||
/// Create a HTTP header name with the provided String.
|
||||
public init(_ name: String) {
|
||||
original = name
|
||||
lowercased = name.lowercased()
|
||||
hashValue = lowercased.hashValue
|
||||
}
|
||||
|
||||
public init(stringLiteral: String) {
|
||||
self.init(stringLiteral)
|
||||
}
|
||||
|
||||
public init(unicodeScalarLiteral: String) {
|
||||
self.init(unicodeScalarLiteral)
|
||||
}
|
||||
|
||||
public init(extendedGraphemeClusterLiteral: String) {
|
||||
self.init(extendedGraphemeClusterLiteral)
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public var description: String {
|
||||
return original
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public static func == (lhs: Name, rhs: Name) -> Bool {
|
||||
return lhs.lowercased == rhs.lowercased
|
||||
}
|
||||
|
||||
// https://www.iana.org/assignments/message-headers/message-headers.xhtml
|
||||
// Permanent Message Header Field Names
|
||||
|
||||
/// A-IM header.
|
||||
public static let aIM = Name("A-IM")
|
||||
/// Accept header.
|
||||
public static let accept = Name("Accept")
|
||||
/// Accept-Additions header.
|
||||
public static let acceptAdditions = Name("Accept-Additions")
|
||||
/// Accept-Charset header.
|
||||
public static let acceptCharset = Name("Accept-Charset")
|
||||
/// Accept-Datetime header.
|
||||
public static let acceptDatetime = Name("Accept-Datetime")
|
||||
/// Accept-Encoding header.
|
||||
public static let acceptEncoding = Name("Accept-Encoding")
|
||||
/// Accept-Features header.
|
||||
public static let acceptFeatures = Name("Accept-Features")
|
||||
/// Accept-Language header.
|
||||
public static let acceptLanguage = Name("Accept-Language")
|
||||
/// Accept-Patch header.
|
||||
public static let acceptPatch = Name("Accept-Patch")
|
||||
/// Accept-Post header.
|
||||
public static let acceptPost = Name("Accept-Post")
|
||||
/// Accept-Ranges header.
|
||||
public static let acceptRanges = Name("Accept-Ranges")
|
||||
/// Accept-Age header.
|
||||
public static let age = Name("Age")
|
||||
/// Accept-Allow header.
|
||||
public static let allow = Name("Allow")
|
||||
/// ALPN header.
|
||||
public static let alpn = Name("ALPN")
|
||||
/// Alt-Svc header.
|
||||
public static let altSvc = Name("Alt-Svc")
|
||||
/// Alt-Used header.
|
||||
public static let altUsed = Name("Alt-Used")
|
||||
/// Alternatives header.
|
||||
public static let alternates = Name("Alternates")
|
||||
/// Apply-To-Redirect-Ref header.
|
||||
public static let applyToRedirectRef = Name("Apply-To-Redirect-Ref")
|
||||
/// Authentication-Control header.
|
||||
public static let authenticationControl = Name("Authentication-Control")
|
||||
/// Authentication-Info header.
|
||||
public static let authenticationInfo = Name("Authentication-Info")
|
||||
/// Authorization header.
|
||||
public static let authorization = Name("Authorization")
|
||||
/// C-Ext header.
|
||||
public static let cExt = Name("C-Ext")
|
||||
/// C-Man header.
|
||||
public static let cMan = Name("C-Man")
|
||||
/// C-Opt header.
|
||||
public static let cOpt = Name("C-Opt")
|
||||
/// C-PEP header.
|
||||
public static let cPEP = Name("C-PEP")
|
||||
/// C-PEP-Indo header.
|
||||
public static let cPEPInfo = Name("C-PEP-Info")
|
||||
/// Cache-Control header.
|
||||
public static let cacheControl = Name("Cache-Control")
|
||||
/// CalDav-Timezones header.
|
||||
public static let calDAVTimezones = Name("CalDAV-Timezones")
|
||||
/// Close header.
|
||||
public static let close = Name("Close")
|
||||
/// Connection header.
|
||||
public static let connection = Name("Connection")
|
||||
/// Content-Base.
|
||||
public static let contentBase = Name("Content-Base")
|
||||
/// Content-Disposition header.
|
||||
public static let contentDisposition = Name("Content-Disposition")
|
||||
/// Content-Encoding header.
|
||||
public static let contentEncoding = Name("Content-Encoding")
|
||||
/// Content-ID header.
|
||||
public static let contentID = Name("Content-ID")
|
||||
/// Content-Language header.
|
||||
public static let contentLanguage = Name("Content-Language")
|
||||
/// Content-Length header.
|
||||
public static let contentLength = Name("Content-Length")
|
||||
/// Content-Location header.
|
||||
public static let contentLocation = Name("Content-Location")
|
||||
/// Content-MD5 header.
|
||||
public static let contentMD5 = Name("Content-MD5")
|
||||
/// Content-Range header.
|
||||
public static let contentRange = Name("Content-Range")
|
||||
/// Content-Script-Type header.
|
||||
public static let contentScriptType = Name("Content-Script-Type")
|
||||
/// Content-Style-Type header.
|
||||
public static let contentStyleType = Name("Content-Style-Type")
|
||||
/// Content-Type header.
|
||||
public static let contentType = Name("Content-Type")
|
||||
/// Content-Version header.
|
||||
public static let contentVersion = Name("Content-Version")
|
||||
/// Content-Cookie header.
|
||||
public static let cookie = Name("Cookie")
|
||||
/// Content-Cookie2 header.
|
||||
public static let cookie2 = Name("Cookie2")
|
||||
/// DASL header.
|
||||
public static let dasl = Name("DASL")
|
||||
/// DASV header.
|
||||
public static let dav = Name("DAV")
|
||||
/// Date header.
|
||||
public static let date = Name("Date")
|
||||
/// Default-Style header.
|
||||
public static let defaultStyle = Name("Default-Style")
|
||||
/// Delta-Base header.
|
||||
public static let deltaBase = Name("Delta-Base")
|
||||
/// Depth header.
|
||||
public static let depth = Name("Depth")
|
||||
/// Derived-From header.
|
||||
public static let derivedFrom = Name("Derived-From")
|
||||
/// Destination header.
|
||||
public static let destination = Name("Destination")
|
||||
/// Differential-ID header.
|
||||
public static let differentialID = Name("Differential-ID")
|
||||
/// Digest header.
|
||||
public static let digest = Name("Digest")
|
||||
/// ETag header.
|
||||
public static let eTag = Name("ETag")
|
||||
/// Expect header.
|
||||
public static let expect = Name("Expect")
|
||||
/// Expires header.
|
||||
public static let expires = Name("Expires")
|
||||
/// Ext header.
|
||||
public static let ext = Name("Ext")
|
||||
/// Forwarded header.
|
||||
public static let forwarded = Name("Forwarded")
|
||||
/// From header.
|
||||
public static let from = Name("From")
|
||||
/// GetProfile header.
|
||||
public static let getProfile = Name("GetProfile")
|
||||
/// Hobareg header.
|
||||
public static let hobareg = Name("Hobareg")
|
||||
/// Host header.
|
||||
public static let host = Name("Host")
|
||||
/// HTTP2-Settings header.
|
||||
public static let http2Settings = Name("HTTP2-Settings")
|
||||
/// IM header.
|
||||
public static let im = Name("IM")
|
||||
/// If header.
|
||||
public static let `if` = Name("If")
|
||||
/// If-Match header.
|
||||
public static let ifMatch = Name("If-Match")
|
||||
/// If-Modified-Since header.
|
||||
public static let ifModifiedSince = Name("If-Modified-Since")
|
||||
/// If-None-Match header.
|
||||
public static let ifNoneMatch = Name("If-None-Match")
|
||||
/// If-Range header.
|
||||
public static let ifRange = Name("If-Range")
|
||||
/// If-Schedule-Tag-Match header.
|
||||
public static let ifScheduleTagMatch = Name("If-Schedule-Tag-Match")
|
||||
/// If-Unmodified-Since header.
|
||||
public static let ifUnmodifiedSince = Name("If-Unmodified-Since")
|
||||
/// Keep-Alive header.
|
||||
public static let keepAlive = Name("Keep-Alive")
|
||||
/// Label header.
|
||||
public static let label = Name("Label")
|
||||
/// Last-Modified header.
|
||||
public static let lastModified = Name("Last-Modified")
|
||||
/// Link header.
|
||||
public static let link = Name("Link")
|
||||
/// Location header.
|
||||
public static let location = Name("Location")
|
||||
/// Lock-Token header.
|
||||
public static let lockToken = Name("Lock-Token")
|
||||
/// Man header.
|
||||
public static let man = Name("Man")
|
||||
/// Max-Forwards header.
|
||||
public static let maxForwards = Name("Max-Forwards")
|
||||
/// Memento-Date header.
|
||||
public static let mementoDatetime = Name("Memento-Datetime")
|
||||
/// Meter header.
|
||||
public static let meter = Name("Meter")
|
||||
/// MIME-Version header.
|
||||
public static let mimeVersion = Name("MIME-Version")
|
||||
/// Negotiate header.
|
||||
public static let negotiate = Name("Negotiate")
|
||||
/// Opt header.
|
||||
public static let opt = Name("Opt")
|
||||
/// Optional-WWW-Authenticate header.
|
||||
public static let optionalWWWAuthenticate = Name("Optional-WWW-Authenticate")
|
||||
/// Ordering-Type header.
|
||||
public static let orderingType = Name("Ordering-Type")
|
||||
/// Origin header.
|
||||
public static let origin = Name("Origin")
|
||||
/// Overwrite header.
|
||||
public static let overwrite = Name("Overwrite")
|
||||
/// P3P header.
|
||||
public static let p3p = Name("P3P")
|
||||
/// PEP header.
|
||||
public static let pep = Name("PEP")
|
||||
/// PICS-Label header.
|
||||
public static let picsLabel = Name("PICS-Label")
|
||||
/// Pep-Info header.
|
||||
public static let pepInfo = Name("Pep-Info")
|
||||
/// Position header.
|
||||
public static let position = Name("Position")
|
||||
/// Pragma header.
|
||||
public static let pragma = Name("Pragma")
|
||||
/// Prefer header.
|
||||
public static let prefer = Name("Prefer")
|
||||
/// Preference-Applied header.
|
||||
public static let preferenceApplied = Name("Preference-Applied")
|
||||
/// ProfileObject header.
|
||||
public static let profileObject = Name("ProfileObject")
|
||||
/// Protocol header.
|
||||
public static let `protocol` = Name("Protocol")
|
||||
/// Protocol-Info header.
|
||||
public static let protocolInfo = Name("Protocol-Info")
|
||||
/// Protocol-Query header.
|
||||
public static let protocolQuery = Name("Protocol-Query")
|
||||
/// Protocol-Request header.
|
||||
public static let protocolRequest = Name("Protocol-Request")
|
||||
/// Proxy-Authenticate header.
|
||||
public static let proxyAuthenticate = Name("Proxy-Authenticate")
|
||||
/// Proxy-Authentication-Info header.
|
||||
public static let proxyAuthenticationInfo = Name("Proxy-Authentication-Info")
|
||||
/// Proxy-Authorization header.
|
||||
public static let proxyAuthorization = Name("Proxy-Authorization")
|
||||
/// Proxy-Features header.
|
||||
public static let proxyFeatures = Name("Proxy-Features")
|
||||
/// Proxy-Instruction header.
|
||||
public static let proxyInstruction = Name("Proxy-Instruction")
|
||||
/// Public header.
|
||||
public static let `public` = Name("Public")
|
||||
/// Public-Key-Pins header.
|
||||
public static let publicKeyPins = Name("Public-Key-Pins")
|
||||
/// Public-Key-Pins-Report-Only header.
|
||||
public static let publicKeyPinsReportOnly = Name("Public-Key-Pins-Report-Only")
|
||||
/// Range header.
|
||||
public static let range = Name("Range")
|
||||
/// Redirect-Ref header.
|
||||
public static let redirectRef = Name("Redirect-Ref")
|
||||
/// Referer header.
|
||||
public static let referer = Name("Referer")
|
||||
/// Retry-After header.
|
||||
public static let retryAfter = Name("Retry-After")
|
||||
/// Safe header.
|
||||
public static let safe = Name("Safe")
|
||||
/// Schedule-Reply header.
|
||||
public static let scheduleReply = Name("Schedule-Reply")
|
||||
/// Schedule-Tag header.
|
||||
public static let scheduleTag = Name("Schedule-Tag")
|
||||
/// Sec-WebSocket-Accept header.
|
||||
public static let secWebSocketAccept = Name("Sec-WebSocket-Accept")
|
||||
/// Sec-WebSocket-Extensions header.
|
||||
public static let secWebSocketExtensions = Name("Sec-WebSocket-Extensions")
|
||||
/// Sec-WebSocket-Key header.
|
||||
public static let secWebSocketKey = Name("Sec-WebSocket-Key")
|
||||
/// Sec-WebSocket-Protocol header.
|
||||
public static let secWebSocketProtocol = Name("Sec-WebSocket-Protocol")
|
||||
/// Sec-WebSocket-Version header.
|
||||
public static let secWebSocketVersion = Name("Sec-WebSocket-Version")
|
||||
/// Security-Scheme header.
|
||||
public static let securityScheme = Name("Security-Scheme")
|
||||
/// Server header.
|
||||
public static let server = Name("Server")
|
||||
/// Set-Cookie header.
|
||||
public static let setCookie = Name("Set-Cookie")
|
||||
/// Set-Cookie2 header.
|
||||
public static let setCookie2 = Name("Set-Cookie2")
|
||||
/// SetProfile header.
|
||||
public static let setProfile = Name("SetProfile")
|
||||
/// SLUG header.
|
||||
public static let slug = Name("SLUG")
|
||||
/// SoapAction header.
|
||||
public static let soapAction = Name("SoapAction")
|
||||
/// Status-URI header.
|
||||
public static let statusURI = Name("Status-URI")
|
||||
/// Strict-Transport-Security header.
|
||||
public static let strictTransportSecurity = Name("Strict-Transport-Security")
|
||||
/// Surrogate-Capability header.
|
||||
public static let surrogateCapability = Name("Surrogate-Capability")
|
||||
/// Surrogate-Control header.
|
||||
public static let surrogateControl = Name("Surrogate-Control")
|
||||
/// TCN header.
|
||||
public static let tcn = Name("TCN")
|
||||
/// TE header.
|
||||
public static let te = Name("TE")
|
||||
/// Timeout header.
|
||||
public static let timeout = Name("Timeout")
|
||||
/// Topic header.
|
||||
public static let topic = Name("Topic")
|
||||
/// Trailer header.
|
||||
public static let trailer = Name("Trailer")
|
||||
/// Transfer-Encoding header.
|
||||
public static let transferEncoding = Name("Transfer-Encoding")
|
||||
/// TTL header.
|
||||
public static let ttl = Name("TTL")
|
||||
/// Urgency header.
|
||||
public static let urgency = Name("Urgency")
|
||||
/// URI header.
|
||||
public static let uri = Name("URI")
|
||||
/// Upgrade header.
|
||||
public static let upgrade = Name("Upgrade")
|
||||
/// User-Agent header.
|
||||
public static let userAgent = Name("User-Agent")
|
||||
/// Variant-Vary header.
|
||||
public static let variantVary = Name("Variant-Vary")
|
||||
/// Vary header.
|
||||
public static let vary = Name("Vary")
|
||||
/// Via header.
|
||||
public static let via = Name("Via")
|
||||
/// WWW-Authenticate header.
|
||||
public static let wwwAuthenticate = Name("WWW-Authenticate")
|
||||
/// Want-Digest header.
|
||||
public static let wantDigest = Name("Want-Digest")
|
||||
/// Warning header.
|
||||
public static let warning = Name("Warning")
|
||||
/// X-Frame-Options header.
|
||||
public static let xFrameOptions = Name("X-Frame-Options")
|
||||
|
||||
// https://www.iana.org/assignments/message-headers/message-headers.xhtml
|
||||
// Provisional Message Header Field Names
|
||||
/// Access-Control header.
|
||||
public static let accessControl = Name("Access-Control")
|
||||
/// Access-Control-Allow-Credentials header.
|
||||
public static let accessControlAllowCredentials = Name("Access-Control-Allow-Credentials")
|
||||
/// Access-Control-Allow-Headers header.
|
||||
public static let accessControlAllowHeaders = Name("Access-Control-Allow-Headers")
|
||||
/// Access-Control-Allow-Methods header.
|
||||
public static let accessControlAllowMethods = Name("Access-Control-Allow-Methods")
|
||||
/// Access-Control-Allow-Origin header.
|
||||
public static let accessControlAllowOrigin = Name("Access-Control-Allow-Origin")
|
||||
/// Access-Control-Max-Age header.
|
||||
public static let accessControlMaxAge = Name("Access-Control-Max-Age")
|
||||
/// Access-Control-Request-Method header.
|
||||
public static let accessControlRequestMethod = Name("Access-Control-Request-Method")
|
||||
/// Access-Control-Request-Headers header.
|
||||
public static let accessControlRequestHeaders = Name("Access-Control-Request-Headers")
|
||||
/// Compliance header.
|
||||
public static let compliance = Name("Compliance")
|
||||
/// Content-Transfer-Encoding header.
|
||||
public static let contentTransferEncoding = Name("Content-Transfer-Encoding")
|
||||
/// Cost header.
|
||||
public static let cost = Name("Cost")
|
||||
/// EDIINT-Features header.
|
||||
public static let ediintFeatures = Name("EDIINT-Features")
|
||||
/// Message-ID header.
|
||||
public static let messageID = Name("Message-ID")
|
||||
/// Method-Check header.
|
||||
public static let methodCheck = Name("Method-Check")
|
||||
/// Method-Check-Expires header.
|
||||
public static let methodCheckExpires = Name("Method-Check-Expires")
|
||||
/// Non-Compliance header.
|
||||
public static let nonCompliance = Name("Non-Compliance")
|
||||
/// Optional header.
|
||||
public static let optional = Name("Optional")
|
||||
/// Referer-Root header.
|
||||
public static let refererRoot = Name("Referer-Root")
|
||||
/// Resolution-Hint header.
|
||||
public static let resolutionHint = Name("Resolution-Hint")
|
||||
/// Resolver-Location header.
|
||||
public static let resolverLocation = Name("Resolver-Location")
|
||||
/// SubOK header.
|
||||
public static let subOK = Name("SubOK")
|
||||
/// Subst header.
|
||||
public static let subst = Name("Subst")
|
||||
/// Title header.
|
||||
public static let title = Name("Title")
|
||||
/// UA-Color header.
|
||||
public static let uaColor = Name("UA-Color")
|
||||
/// UA-Media header.
|
||||
public static let uaMedia = Name("UA-Media")
|
||||
/// UA-Pixels header.
|
||||
public static let uaPixels = Name("UA-Pixels")
|
||||
/// UA-Resolution header.
|
||||
public static let uaResolution = Name("UA-Resolution")
|
||||
/// UA-Windowpixels header.
|
||||
public static let uaWindowpixels = Name("UA-Windowpixels")
|
||||
/// Version header.
|
||||
public static let version = Name("Version")
|
||||
/// X-Device-Accept header.
|
||||
public static let xDeviceAccept = Name("X-Device-Accept")
|
||||
/// X-Device-Accept-Charset header.
|
||||
public static let xDeviceAcceptCharset = Name("X-Device-Accept-Charset")
|
||||
/// X-Device-Accept-Encoding header.
|
||||
public static let xDeviceAcceptEncoding = Name("X-Device-Accept-Encoding")
|
||||
/// X-Device-Accept-Language header.
|
||||
public static let xDeviceAcceptLanguage = Name("X-Device-Accept-Language")
|
||||
/// X-Device-User-Agent header.
|
||||
public static let xDeviceUserAgent = Name("X-Device-User-Agent")
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
/// HTTP method structure
|
||||
public struct HTTPMethod {
|
||||
/// HTTP method
|
||||
public let method: String
|
||||
|
||||
/// Creates an HTTP method
|
||||
public init(_ method: String) {
|
||||
self.method = method.uppercased()
|
||||
}
|
||||
}
|
||||
|
||||
/// HTTP method constants
|
||||
extension HTTPMethod {
|
||||
/// DELETE method.
|
||||
public static let delete = HTTPMethod("DELETE")
|
||||
/// GET method.
|
||||
public static let get = HTTPMethod("GET")
|
||||
/// HEAD method.
|
||||
public static let head = HTTPMethod("HEAD")
|
||||
/// POST method.
|
||||
public static let post = HTTPMethod("POST")
|
||||
/// PUT method.
|
||||
public static let put = HTTPMethod("PUT")
|
||||
/// CONNECT method.
|
||||
public static let connect = HTTPMethod("CONNECT")
|
||||
/// OPTIONS method.
|
||||
public static let options = HTTPMethod("OPTIONS")
|
||||
/// TRACE method.
|
||||
public static let trace = HTTPMethod("TRACE")
|
||||
/// COPY method.
|
||||
public static let copy = HTTPMethod("COPY")
|
||||
/// LOCK method.
|
||||
public static let lock = HTTPMethod("LOCK")
|
||||
/// MKCOL method.
|
||||
public static let mkcol = HTTPMethod("MKCOL")
|
||||
/// MOVE method.
|
||||
public static let move = HTTPMethod("MOVE")
|
||||
/// PROPFIND method.
|
||||
public static let propfind = HTTPMethod("PROPFIND")
|
||||
/// PROPPATCH method.
|
||||
public static let proppatch = HTTPMethod("PROPPATCH")
|
||||
/// SEARCH method.
|
||||
public static let search = HTTPMethod("SEARCH")
|
||||
/// UNLOCK method.
|
||||
public static let unlock = HTTPMethod("UNLOCK")
|
||||
/// BIND method.
|
||||
public static let bind = HTTPMethod("BIND")
|
||||
/// REBIND method.
|
||||
public static let rebind = HTTPMethod("REBIND")
|
||||
/// UNBIND method.
|
||||
public static let unbind = HTTPMethod("UNBIND")
|
||||
/// ACL method.
|
||||
public static let acl = HTTPMethod("ACL")
|
||||
/// REPORT method.
|
||||
public static let report = HTTPMethod("REPORT")
|
||||
/// MKACTIVITY method.
|
||||
public static let mkactivity = HTTPMethod("MKACTIVITY")
|
||||
/// CHECKOUT method.
|
||||
public static let checkout = HTTPMethod("CHECKOUT")
|
||||
/// MERGE method.
|
||||
public static let merge = HTTPMethod("MERGE")
|
||||
/// MSEARCH method.
|
||||
public static let msearch = HTTPMethod("MSEARCH")
|
||||
/// NOTIFY method.
|
||||
public static let notify = HTTPMethod("NOTIFY")
|
||||
/// SUBSCRIBE method.
|
||||
public static let subscribe = HTTPMethod("SUBSCRIBE")
|
||||
/// UNSUBSCRIBE method.
|
||||
public static let unsubscribe = HTTPMethod("UNSUBSCRIBE")
|
||||
/// PATCH method.
|
||||
public static let patch = HTTPMethod("PATCH")
|
||||
/// PURGE method.
|
||||
public static let purge = HTTPMethod("PURGE")
|
||||
/// MKCALENDAR method.
|
||||
public static let mkcalendar = HTTPMethod("MKCALENDAR")
|
||||
/// LINK method.
|
||||
public static let link = HTTPMethod("LINK")
|
||||
/// UNLINK method.
|
||||
public static let unlink = HTTPMethod("UNLINK")
|
||||
}
|
||||
|
||||
extension HTTPMethod: Hashable {
|
||||
public var hashValue: Int {
|
||||
return method.hashValue
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public static func == (lhs: HTTPMethod, rhs: HTTPMethod) -> Bool {
|
||||
return lhs.method == rhs.method
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public static func ~= (match: HTTPMethod, version: HTTPMethod) -> Bool {
|
||||
return match == version
|
||||
}
|
||||
}
|
||||
|
||||
extension HTTPMethod: ExpressibleByStringLiteral {
|
||||
/// :nodoc:
|
||||
public init(stringLiteral: String) {
|
||||
self.init(stringLiteral)
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public init(unicodeScalarLiteral: String) {
|
||||
self.init(unicodeScalarLiteral)
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public init(extendedGraphemeClusterLiteral: String) {
|
||||
self.init(extendedGraphemeClusterLiteral)
|
||||
}
|
||||
}
|
||||
|
||||
extension HTTPMethod: CustomStringConvertible {
|
||||
/// :nodoc:
|
||||
public var description: String {
|
||||
return method
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import Dispatch
|
||||
import Foundation
|
||||
|
||||
/// A structure representing the headers from a HTTP request, without the body of the request.
|
||||
public struct HTTPRequest {
|
||||
/// HTTP request method.
|
||||
public var method: HTTPMethod
|
||||
/// HTTP request URI, eg. "/foo/bar?buz=qux"
|
||||
public var target: String
|
||||
/// HTTP request version
|
||||
public var httpVersion: HTTPVersion
|
||||
/// HTTP request headers
|
||||
public var headers: HTTPHeaders
|
||||
}
|
||||
|
||||
/// Method that takes a chunk of request body and is expected to write to the `HTTPResponseWriter`
|
||||
/// - Parameter HTTPBodyChunk: `HTTPBodyChunk` representing some or all of the incoming request body
|
||||
/// - Parameter Bool: A boolean flag that can be set to true in order to prevent further processing
|
||||
public typealias HTTPBodyHandler = (HTTPBodyChunk, inout Bool) -> Void
|
||||
|
||||
/// Indicates whether the body is going to be processed or ignored
|
||||
public enum HTTPBodyProcessing {
|
||||
/// Used to discard the body data associated with the incoming HTTP request
|
||||
case discardBody
|
||||
/// Used to process the body data associated with the incoming HTTP request using a `HTTPBodyHandler`
|
||||
case processBody(handler: HTTPBodyHandler)
|
||||
}
|
||||
|
||||
/// Part or all of the incoming request body
|
||||
public enum HTTPBodyChunk {
|
||||
/// A new chunk of the incoming HTTP reqest body data has arrived. `finishedProcessing()` must be called when
|
||||
/// that chunk has been processed.
|
||||
case chunk(data: DispatchData, finishedProcessing: () -> Void)
|
||||
/// An error has occurred whilst streaming the incoming HTTP request data, eg. the connection closed
|
||||
case failed(error: Error)
|
||||
/// A trailer header has arrived during the processing of the incoming HTTP request data.
|
||||
/// This is currently unimplemented.
|
||||
case trailer(key: String, value: String)
|
||||
/// The stream of incoming HTTP request data has completed.
|
||||
case end
|
||||
}
|
||||
@@ -1,391 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Dispatch
|
||||
|
||||
/// A structure representing the headers for a HTTP response, without the body of the response.
|
||||
public struct HTTPResponse {
|
||||
/// HTTP response version
|
||||
public var httpVersion: HTTPVersion
|
||||
/// HTTP response status
|
||||
public var status: HTTPResponseStatus
|
||||
/// HTTP response headers
|
||||
public var headers: HTTPHeaders
|
||||
}
|
||||
|
||||
/// HTTPResponseWriter provides functions to create an HTTP response
|
||||
public protocol HTTPResponseWriter: class {
|
||||
/// Writer function to create the headers for an HTTP response
|
||||
/// - Parameter status: The status code to include in the HTTP response
|
||||
/// - Parameter headers: The HTTP headers to include in the HTTP response
|
||||
/// - Parameter completion: Closure that is called when the HTTP headers have been written to the HTTP respose
|
||||
func writeHeader(status: HTTPResponseStatus, headers: HTTPHeaders, completion: @escaping (Result) -> Void)
|
||||
|
||||
/// Writer function to write a trailer header as part of the HTTP response
|
||||
/// - Parameter trailers: The trailers to write as part of the HTTP response
|
||||
/// - Parameter completion: Closure that is called when the trailers has been written to the HTTP response
|
||||
/// This is not currently implemented
|
||||
func writeTrailer(_ trailers: HTTPHeaders, completion: @escaping (Result) -> Void)
|
||||
|
||||
/// Writer function to write data to the body of the HTTP response
|
||||
/// - Parameter data: The data to write as part of the HTTP response
|
||||
/// - Parameter completion: Closure that is called when the data has been written to the HTTP response
|
||||
func writeBody(_ data: UnsafeHTTPResponseBody, completion: @escaping (Result) -> Void)
|
||||
|
||||
/// Writer function to complete the HTTP response
|
||||
/// - Parameter completion: Closure that is called when the HTTP response has been completed
|
||||
func done(completion: @escaping (Result) -> Void)
|
||||
|
||||
/// abort: Abort the HTTP response
|
||||
func abort()
|
||||
}
|
||||
|
||||
/// Convenience methods for HTTP response writer.
|
||||
extension HTTPResponseWriter {
|
||||
/// Convenience function to write the headers for an HTTP response without a completion handler
|
||||
/// - See: `writeHeader(status:headers:completion:)`
|
||||
public func writeHeader(status: HTTPResponseStatus, headers: HTTPHeaders) {
|
||||
writeHeader(status: status, headers: headers) { _ in }
|
||||
}
|
||||
|
||||
/// Convenience function to write a HTTP response with no headers or completion handler
|
||||
/// - See: `writeHeader(status:headers:completion:)`
|
||||
public func writeHeader(status: HTTPResponseStatus) {
|
||||
writeHeader(status: status, headers: [:])
|
||||
}
|
||||
|
||||
/// Convenience function to write a trailer header as part of the HTTP response without a completion handler
|
||||
/// - See: `writeTrailer(_:completion:)`
|
||||
public func writeTrailer(_ trailers: HTTPHeaders) {
|
||||
writeTrailer(trailers) { _ in }
|
||||
}
|
||||
|
||||
/// Convenience function for writing `data` to the body of the HTTP response without a completion handler.
|
||||
/// - See: writeBody(_:completion:)
|
||||
public func writeBody(_ data: UnsafeHTTPResponseBody) {
|
||||
return writeBody(data) { _ in }
|
||||
}
|
||||
|
||||
/// Convenience function to complete the HTTP response without a completion handler.
|
||||
/// - See: done(completion:)
|
||||
public func done() {
|
||||
done { _ in }
|
||||
}
|
||||
}
|
||||
|
||||
/// The response status for the HTTP response
|
||||
/// - See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml for more information
|
||||
public struct HTTPResponseStatus: Equatable, CustomStringConvertible, ExpressibleByIntegerLiteral {
|
||||
/// The status code, eg. 200 or 404
|
||||
public let code: Int
|
||||
/// The reason phrase for the status code
|
||||
public let reasonPhrase: String
|
||||
|
||||
/// Creates an HTTP response status
|
||||
/// - Parameter code: The status code used for the response status
|
||||
/// - Parameter reasonPhrase: The reason phrase to use for the response status
|
||||
public init(code: Int, reasonPhrase: String) {
|
||||
self.code = code
|
||||
self.reasonPhrase = reasonPhrase
|
||||
}
|
||||
|
||||
/// Creates an HTTP response status
|
||||
/// The reason phrase is added for the status code, or "http_(code)" if the code is not well known
|
||||
/// - Parameter code: The status code used for the response status
|
||||
public init(code: Int) {
|
||||
self.init(code: code, reasonPhrase: HTTPResponseStatus.defaultReasonPhrase(forCode: code))
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public init(integerLiteral: Int) {
|
||||
self.init(code: integerLiteral)
|
||||
}
|
||||
|
||||
/* all the codes from http://www.iana.org/assignments/http-status-codes */
|
||||
/// 100 Continue
|
||||
public static let `continue` = HTTPResponseStatus(code: 100)
|
||||
/// 101 Switching Protocols
|
||||
public static let switchingProtocols = HTTPResponseStatus(code: 101)
|
||||
/// 200 OK
|
||||
public static let ok = HTTPResponseStatus(code: 200)
|
||||
/// 201 Created
|
||||
public static let created = HTTPResponseStatus(code: 201)
|
||||
/// 202 Accepted
|
||||
public static let accepted = HTTPResponseStatus(code: 202)
|
||||
/// 203 Non-Authoritative Information
|
||||
public static let nonAuthoritativeInformation = HTTPResponseStatus(code: 203)
|
||||
/// 204 No Content
|
||||
public static let noContent = HTTPResponseStatus(code: 204)
|
||||
/// 205 Reset Content
|
||||
public static let resetContent = HTTPResponseStatus(code: 205)
|
||||
/// 206 Partial Content
|
||||
public static let partialContent = HTTPResponseStatus(code: 206)
|
||||
/// 207 Multi-Status
|
||||
public static let multiStatus = HTTPResponseStatus(code: 207)
|
||||
/// 208 Already Reported
|
||||
public static let alreadyReported = HTTPResponseStatus(code: 208)
|
||||
/// 226 IM Used
|
||||
public static let imUsed = HTTPResponseStatus(code: 226)
|
||||
/// 300 Multiple Choices
|
||||
public static let multipleChoices = HTTPResponseStatus(code: 300)
|
||||
/// 301 Moved Permanently
|
||||
public static let movedPermanently = HTTPResponseStatus(code: 301)
|
||||
/// 302 Found
|
||||
public static let found = HTTPResponseStatus(code: 302)
|
||||
/// 303 See Other
|
||||
public static let seeOther = HTTPResponseStatus(code: 303)
|
||||
/// 304 Not Modified
|
||||
public static let notModified = HTTPResponseStatus(code: 304)
|
||||
/// 305 Use Proxy
|
||||
public static let useProxy = HTTPResponseStatus(code: 305)
|
||||
/// 307 Temporary Redirect
|
||||
public static let temporaryRedirect = HTTPResponseStatus(code: 307)
|
||||
/// 308 Permanent Redirect
|
||||
public static let permanentRedirect = HTTPResponseStatus(code: 308)
|
||||
/// 400 Bad Request
|
||||
public static let badRequest = HTTPResponseStatus(code: 400)
|
||||
/// 401 Unauthorized
|
||||
public static let unauthorized = HTTPResponseStatus(code: 401)
|
||||
/// 402 Payment Required
|
||||
public static let paymentRequired = HTTPResponseStatus(code: 402)
|
||||
/// 403 Forbidden
|
||||
public static let forbidden = HTTPResponseStatus(code: 403)
|
||||
/// 404 Not Found
|
||||
public static let notFound = HTTPResponseStatus(code: 404)
|
||||
/// 405 Method Not Allowed
|
||||
public static let methodNotAllowed = HTTPResponseStatus(code: 405)
|
||||
/// 406 Not Acceptable
|
||||
public static let notAcceptable = HTTPResponseStatus(code: 406)
|
||||
/// 407 Proxy Authentication Required
|
||||
public static let proxyAuthenticationRequired = HTTPResponseStatus(code: 407)
|
||||
/// 408 Request Timeout
|
||||
public static let requestTimeout = HTTPResponseStatus(code: 408)
|
||||
/// 409 Conflict
|
||||
public static let conflict = HTTPResponseStatus(code: 409)
|
||||
/// 410 Gone
|
||||
public static let gone = HTTPResponseStatus(code: 410)
|
||||
/// 411 Length Required
|
||||
public static let lengthRequired = HTTPResponseStatus(code: 411)
|
||||
/// 412 Precondition Failed
|
||||
public static let preconditionFailed = HTTPResponseStatus(code: 412)
|
||||
/// 413 Payload Too Large
|
||||
public static let payloadTooLarge = HTTPResponseStatus(code: 413)
|
||||
/// 414 URI Too Long
|
||||
public static let uriTooLong = HTTPResponseStatus(code: 414)
|
||||
/// 415 Unsupported Media Type
|
||||
public static let unsupportedMediaType = HTTPResponseStatus(code: 415)
|
||||
/// 416 Range Not Satisfiable
|
||||
public static let rangeNotSatisfiable = HTTPResponseStatus(code: 416)
|
||||
/// 417 Expectation Failed
|
||||
public static let expectationFailed = HTTPResponseStatus(code: 417)
|
||||
/// 421 Misdirected Request
|
||||
public static let misdirectedRequest = HTTPResponseStatus(code: 421)
|
||||
/// 422 Unprocessable Entity
|
||||
public static let unprocessableEntity = HTTPResponseStatus(code: 422)
|
||||
/// 423 Locked
|
||||
public static let locked = HTTPResponseStatus(code: 423)
|
||||
/// 424 Failed Dependency
|
||||
public static let failedDependency = HTTPResponseStatus(code: 424)
|
||||
/// 426 Upgrade Required
|
||||
public static let upgradeRequired = HTTPResponseStatus(code: 426)
|
||||
/// 428 Precondition Required
|
||||
public static let preconditionRequired = HTTPResponseStatus(code: 428)
|
||||
/// 429 Too Many Requests
|
||||
public static let tooManyRequests = HTTPResponseStatus(code: 429)
|
||||
/// 431 Request Header Fields Too Large
|
||||
public static let requestHeaderFieldsTooLarge = HTTPResponseStatus(code: 431)
|
||||
/// 451 Unavailable For Legal Reasons
|
||||
public static let unavailableForLegalReasons = HTTPResponseStatus(code: 451)
|
||||
/// 500 Internal Server Error
|
||||
public static let internalServerError = HTTPResponseStatus(code: 500)
|
||||
/// 501 Not Implemented
|
||||
public static let notImplemented = HTTPResponseStatus(code: 501)
|
||||
/// 502 Bad Gateway
|
||||
public static let badGateway = HTTPResponseStatus(code: 502)
|
||||
/// 503 Service Unavailable
|
||||
public static let serviceUnavailable = HTTPResponseStatus(code: 503)
|
||||
/// 504 Gateway Timeout
|
||||
public static let gatewayTimeout = HTTPResponseStatus(code: 504)
|
||||
/// 505 HTTP Version Not Supported
|
||||
public static let httpVersionNotSupported = HTTPResponseStatus(code: 505)
|
||||
/// 506 Variant Also Negotiates
|
||||
public static let variantAlsoNegotiates = HTTPResponseStatus(code: 506)
|
||||
/// 507 Insufficient Storage
|
||||
public static let insufficientStorage = HTTPResponseStatus(code: 507)
|
||||
/// 508 Loop Detected
|
||||
public static let loopDetected = HTTPResponseStatus(code: 508)
|
||||
/// 510 Not Extended
|
||||
public static let notExtended = HTTPResponseStatus(code: 510)
|
||||
/// 511 Network Authentication Required
|
||||
public static let networkAuthenticationRequired = HTTPResponseStatus(code: 511)
|
||||
|
||||
// swiftlint:disable cyclomatic_complexity switch_case_on_newline
|
||||
static func defaultReasonPhrase(forCode code: Int) -> String {
|
||||
switch code {
|
||||
case 100: return "Continue"
|
||||
case 101: return "Switching Protocols"
|
||||
case 200: return "OK"
|
||||
case 201: return "Created"
|
||||
case 202: return "Accepted"
|
||||
case 203: return "Non-Authoritative Information"
|
||||
case 204: return "No Content"
|
||||
case 205: return "Reset Content"
|
||||
case 206: return "Partial Content"
|
||||
case 207: return "Multi-Status"
|
||||
case 208: return "Already Reported"
|
||||
case 226: return "IM Used"
|
||||
case 300: return "Multiple Choices"
|
||||
case 301: return "Moved Permanently"
|
||||
case 302: return "Found"
|
||||
case 303: return "See Other"
|
||||
case 304: return "Not Modified"
|
||||
case 305: return "Use Proxy"
|
||||
case 307: return "Temporary Redirect"
|
||||
case 308: return "Permanent Redirect"
|
||||
case 400: return "Bad Request"
|
||||
case 401: return "Unauthorized"
|
||||
case 402: return "Payment Required"
|
||||
case 403: return "Forbidden"
|
||||
case 404: return "Not Found"
|
||||
case 405: return "Method Not Allowed"
|
||||
case 406: return "Not Acceptable"
|
||||
case 407: return "Proxy Authentication Required"
|
||||
case 408: return "Request Timeout"
|
||||
case 409: return "Conflict"
|
||||
case 410: return "Gone"
|
||||
case 411: return "Length Required"
|
||||
case 412: return "Precondition Failed"
|
||||
case 413: return "Payload Too Large"
|
||||
case 414: return "URI Too Long"
|
||||
case 415: return "Unsupported Media Type"
|
||||
case 416: return "Range Not Satisfiable"
|
||||
case 417: return "Expectation Failed"
|
||||
case 421: return "Misdirected Request"
|
||||
case 422: return "Unprocessable Entity"
|
||||
case 423: return "Locked"
|
||||
case 424: return "Failed Dependency"
|
||||
case 426: return "Upgrade Required"
|
||||
case 428: return "Precondition Required"
|
||||
case 429: return "Too Many Requests"
|
||||
case 431: return "Request Header Fields Too Large"
|
||||
case 451: return "Unavailable For Legal Reasons"
|
||||
case 500: return "Internal Server Error"
|
||||
case 501: return "Not Implemented"
|
||||
case 502: return "Bad Gateway"
|
||||
case 503: return "Service Unavailable"
|
||||
case 504: return "Gateway Timeout"
|
||||
case 505: return "HTTP Version Not Supported"
|
||||
case 506: return "Variant Also Negotiates"
|
||||
case 507: return "Insufficient Storage"
|
||||
case 508: return "Loop Detected"
|
||||
case 510: return "Not Extended"
|
||||
case 511: return "Network Authentication Required"
|
||||
default: return "http_\(code)"
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public var description: String {
|
||||
return "\(code) \(reasonPhrase)"
|
||||
}
|
||||
|
||||
/// - The `Class` representing the class of status code for this response status
|
||||
public var `class`: Class {
|
||||
return Class(code: code)
|
||||
}
|
||||
|
||||
/// The class of a `HTTPResponseStatus` code
|
||||
/// - See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml for more information
|
||||
public enum Class {
|
||||
/// Informational: the request was received, and is continuing to be processed
|
||||
case informational
|
||||
/// Success: the action was successfully received, understood, and accepted
|
||||
case successful
|
||||
/// Redirection: further action must be taken in order to complete the request
|
||||
case redirection
|
||||
/// Client Error: the request contains bad syntax or cannot be fulfilled
|
||||
case clientError
|
||||
/// Server Error: the server failed to fulfill an apparently valid request
|
||||
case serverError
|
||||
/// Invalid: the code does not map to a well known status code class
|
||||
case invalidStatus
|
||||
|
||||
init(code: Int) {
|
||||
switch code {
|
||||
case 100..<200: self = .informational
|
||||
case 200..<300: self = .successful
|
||||
case 300..<400: self = .redirection
|
||||
case 400..<500: self = .clientError
|
||||
case 500..<600: self = .serverError
|
||||
default: self = .invalidStatus
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// [RFC2616, section 4.4]
|
||||
var bodyAllowed: Bool {
|
||||
switch code {
|
||||
case 100..<200: return false
|
||||
case 204: return false
|
||||
case 304: return false
|
||||
default: return true
|
||||
}
|
||||
}
|
||||
|
||||
var suppressedHeaders: [HTTPHeaders.Name] {
|
||||
if self == .notModified {
|
||||
return ["Content-Type", "Content-Length", "Transfer-Encoding"]
|
||||
} else if !bodyAllowed {
|
||||
return ["Content-Length", "Transfer-Encoding"]
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public static func == (lhs: HTTPResponseStatus, rhs: HTTPResponseStatus) -> Bool {
|
||||
return lhs.code == rhs.code
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public protocol UnsafeHTTPResponseBody {
|
||||
func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
extension UnsafeRawBufferPointer: UnsafeHTTPResponseBody {
|
||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
||||
return try body(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public protocol HTTPResponseBody: UnsafeHTTPResponseBody {}
|
||||
|
||||
extension Data: HTTPResponseBody {
|
||||
/// :nodoc:
|
||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
||||
return try withUnsafeBytes { try body(UnsafeRawBufferPointer(start: $0, count: count)) }
|
||||
}
|
||||
}
|
||||
|
||||
extension DispatchData: HTTPResponseBody {
|
||||
/// :nodoc:
|
||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
||||
return try withUnsafeBytes { try body(UnsafeRawBufferPointer(start: $0, count: count)) }
|
||||
}
|
||||
}
|
||||
|
||||
extension String: HTTPResponseBody {
|
||||
/// :nodoc:
|
||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
||||
return try ContiguousArray(utf8).withUnsafeBytes(body)
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import ServerSecurity
|
||||
|
||||
/// A basic HTTP server. Currently this is implemented using the PoCSocket
|
||||
/// abstraction, but the intention is to remove this dependency and reimplement
|
||||
/// the class using transport APIs provided by the Server APIs working group.
|
||||
public class HTTPServer {
|
||||
|
||||
/// Configuration options for creating HTTPServer
|
||||
open class Options {
|
||||
/// HTTPServer to be created on a given `port`
|
||||
/// Note: For Port=0, the kernel assigns a random port. This will cause HTTPServer.port value
|
||||
/// to diverge from HTTPServer.Options.port
|
||||
public let port: Int
|
||||
|
||||
public let tlsConfig: TLSConfiguration?
|
||||
|
||||
/// Create an instance of HTTPServerOptions
|
||||
public init(onPort: Int = 0, tlsConf: TLSConfiguration? = nil) {
|
||||
port = onPort
|
||||
tlsConfig = tlsConf
|
||||
}
|
||||
}
|
||||
public let options: Options
|
||||
|
||||
/// To process incoming requests
|
||||
public let handler: HTTPRequestHandler
|
||||
|
||||
private let server = PoCSocketSimpleServer()
|
||||
|
||||
/// Create an instance of the server. This needs to be followed with a call to `start(port:handler:)`
|
||||
public init(with newOptions: Options, requestHandler: @escaping HTTPRequestHandler) {
|
||||
options = newOptions
|
||||
handler = requestHandler
|
||||
}
|
||||
|
||||
/// Start the HTTP server on the given `port` number, using a `HTTPRequestHandler` to process incoming requests.
|
||||
public func start() throws {
|
||||
try server.start(port: options.port, tls: options.tlsConfig, handler: handler)
|
||||
}
|
||||
|
||||
/// Stop the server
|
||||
public func stop() {
|
||||
server.stop()
|
||||
}
|
||||
|
||||
/// The port number the server is listening on
|
||||
public var port: Int {
|
||||
return server.port
|
||||
}
|
||||
|
||||
/// The number of current connections
|
||||
public var connectionCount: Int {
|
||||
return server.connectionCount
|
||||
}
|
||||
}
|
||||
@@ -1,584 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import CHTTPParser
|
||||
import Foundation
|
||||
import Dispatch
|
||||
|
||||
public enum StreamingParserError: Error {
|
||||
case ConnectionAbortedError
|
||||
}
|
||||
|
||||
/// Class that wraps the CHTTPParser and calls the `HTTPRequestHandler` to get the response
|
||||
/// :nodoc:
|
||||
public class StreamingParser: HTTPResponseWriter {
|
||||
|
||||
let handle: HTTPRequestHandler
|
||||
|
||||
/// Time to leave socket open waiting for next request to start
|
||||
public let keepAliveTimeout: TimeInterval
|
||||
|
||||
/// Flag to track if the client wants to send consecutive requests on the same TCP connection
|
||||
var clientRequestedKeepAlive = false
|
||||
|
||||
/// Tracks when socket should be closed. Needs to have a lock, since it's updated often
|
||||
private let _keepAliveUntilLock = DispatchSemaphore(value: 1)
|
||||
private var _keepAliveUntil: TimeInterval?
|
||||
public var keepAliveUntil: TimeInterval? {
|
||||
get {
|
||||
_keepAliveUntilLock.wait()
|
||||
defer {
|
||||
_keepAliveUntilLock.signal()
|
||||
}
|
||||
return _keepAliveUntil
|
||||
}
|
||||
set {
|
||||
_keepAliveUntilLock.wait()
|
||||
defer {
|
||||
_keepAliveUntilLock.signal()
|
||||
}
|
||||
_keepAliveUntil = newValue
|
||||
}
|
||||
}
|
||||
|
||||
/// Tracks when we've been told socket has been closed. Needs to have a lock, since if we get confused, bad things happen
|
||||
private let _abortCalledLock = DispatchSemaphore(value: 1)
|
||||
private var _abortCalled: Bool = false
|
||||
internal var abortCalled: Bool {
|
||||
get {
|
||||
_abortCalledLock.wait()
|
||||
defer {
|
||||
_abortCalledLock.signal()
|
||||
}
|
||||
return _abortCalled
|
||||
}
|
||||
set {
|
||||
_abortCalledLock.wait()
|
||||
defer {
|
||||
_abortCalledLock.signal()
|
||||
}
|
||||
_abortCalled = newValue
|
||||
}
|
||||
}
|
||||
|
||||
/// Optional delegate that can tell us how many connections are in-flight.
|
||||
public weak var connectionCounter: CurrentConnectionCounting?
|
||||
|
||||
/// Holds the bytes that come from the CHTTPParser until we have enough of them to do something with it
|
||||
var parserBuffer: Data?
|
||||
|
||||
/// Lock for parser buffer.
|
||||
private let _parserBufferLock = DispatchSemaphore(value: 1)
|
||||
|
||||
/// HTTP Parser
|
||||
var httpParser = http_parser()
|
||||
var httpParserSettings = http_parser_settings()
|
||||
|
||||
/// Block that takes a chunk from the HTTPParser as input and writes to a Response as a result
|
||||
var httpBodyProcessingCallback: HTTPBodyProcessing?
|
||||
|
||||
//Note: we want this to be strong so it holds onto the connector until it's explicitly cleared
|
||||
/// Protocol that we use to send data (and status info) back to the Network layer
|
||||
public var parserConnector: ParserConnecting?
|
||||
|
||||
///Flag to track whether our handler has told us not to call it anymore
|
||||
private let _shouldStopProcessingBodyLock = DispatchSemaphore(value: 1)
|
||||
private var _shouldStopProcessingBody: Bool = false
|
||||
private var shouldStopProcessingBody: Bool {
|
||||
get {
|
||||
_shouldStopProcessingBodyLock.wait()
|
||||
defer {
|
||||
_shouldStopProcessingBodyLock.signal()
|
||||
}
|
||||
return _shouldStopProcessingBody
|
||||
}
|
||||
set {
|
||||
_shouldStopProcessingBodyLock.wait()
|
||||
defer {
|
||||
_shouldStopProcessingBodyLock.signal()
|
||||
}
|
||||
_shouldStopProcessingBody = newValue
|
||||
}
|
||||
}
|
||||
|
||||
var lastCallBack = CallbackRecord.idle
|
||||
var lastHeaderName: String?
|
||||
var parsedHeaders = HTTPHeaders()
|
||||
var parsedHTTPMethod: HTTPMethod?
|
||||
var parsedHTTPVersion: HTTPVersion?
|
||||
var parsedURL: String?
|
||||
|
||||
/// Is the currently parsed request an upgrade request?
|
||||
public private(set) var upgradeRequested = false
|
||||
|
||||
/// Class that wraps the CHTTPParser and calls the `HTTPRequestHandler` to get the response
|
||||
///
|
||||
/// - Parameter handler: function that is used to create the response
|
||||
public init(handler: @escaping HTTPRequestHandler, connectionCounter: CurrentConnectionCounting? = nil, keepAliveTimeout: Double = 5.0) {
|
||||
self.handle = handler
|
||||
self.connectionCounter = connectionCounter
|
||||
self.keepAliveTimeout = keepAliveTimeout
|
||||
|
||||
//Set up all the callbacks for the CHTTPParser library
|
||||
httpParserSettings.on_message_begin = { parser -> Int32 in
|
||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||
return Int32(0)
|
||||
}
|
||||
return listener.messageBegan()
|
||||
}
|
||||
|
||||
httpParserSettings.on_message_complete = { parser -> Int32 in
|
||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||
return 0
|
||||
}
|
||||
return listener.messageCompleted()
|
||||
}
|
||||
|
||||
httpParserSettings.on_headers_complete = { parser -> Int32 in
|
||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||
return 0
|
||||
}
|
||||
let methodId = parser?.pointee.method
|
||||
let methodName = String(validatingUTF8: http_method_str(http_method(rawValue: methodId ?? 0))) ?? "GET"
|
||||
let major = Int(parser?.pointee.http_major ?? 0)
|
||||
let minor = Int(parser?.pointee.http_minor ?? 0)
|
||||
|
||||
//This needs to be set here and not messageCompleted if it's going to work here
|
||||
let keepAlive = http_should_keep_alive(parser) == 1
|
||||
let upgradeRequested = parser?.pointee.upgrade == 1
|
||||
|
||||
return listener.headersCompleted(methodName: methodName,
|
||||
majorVersion: major,
|
||||
minorVersion: minor,
|
||||
keepAlive: keepAlive,
|
||||
upgrade: upgradeRequested)
|
||||
}
|
||||
|
||||
httpParserSettings.on_header_field = { (parser, chunk, length) -> Int32 in
|
||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||
return 0
|
||||
}
|
||||
return listener.headerFieldReceived(data: chunk, length: length)
|
||||
}
|
||||
|
||||
httpParserSettings.on_header_value = { (parser, chunk, length) -> Int32 in
|
||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||
return 0
|
||||
}
|
||||
return listener.headerValueReceived(data: chunk, length: length)
|
||||
}
|
||||
|
||||
httpParserSettings.on_body = { (parser, chunk, length) -> Int32 in
|
||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||
return 0
|
||||
}
|
||||
return listener.bodyReceived(data: chunk, length: length)
|
||||
}
|
||||
|
||||
httpParserSettings.on_url = { (parser, chunk, length) -> Int32 in
|
||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||
return 0
|
||||
}
|
||||
return listener.urlReceived(data: chunk, length: length)
|
||||
}
|
||||
|
||||
http_parser_init(&httpParser, HTTP_REQUEST)
|
||||
|
||||
self.httpParser.data = Unmanaged.passUnretained(self).toOpaque()
|
||||
}
|
||||
|
||||
/// Read a stream from the network, pass it to the parser and return number of bytes consumed
|
||||
///
|
||||
/// - Parameter data: data coming from network
|
||||
/// - Returns: number of bytes that we sent to the parser
|
||||
public func readStream(data: Data) -> Int {
|
||||
return data.withUnsafeBytes { (ptr) -> Int in
|
||||
return http_parser_execute(&self.httpParser, &self.httpParserSettings, ptr, data.count)
|
||||
}
|
||||
}
|
||||
|
||||
/// States to track where we are in parsing the HTTP Stream from the client
|
||||
enum CallbackRecord {
|
||||
case idle, messageBegan, messageCompleted, headersCompleted, headerFieldReceived, headerValueReceived, bodyReceived, urlReceived
|
||||
}
|
||||
|
||||
/// Process change of state as we get more and more parser callbacks
|
||||
///
|
||||
/// - Parameter currentCallBack: state we are entering, as specified by the CHTTPParser
|
||||
/// - Returns: Whether or not the state actually changed
|
||||
@discardableResult
|
||||
func processCurrentCallback(_ currentCallBack: CallbackRecord) -> Bool {
|
||||
if lastCallBack == currentCallBack {
|
||||
return false
|
||||
}
|
||||
_parserBufferLock.wait()
|
||||
defer { _parserBufferLock.signal() }
|
||||
switch lastCallBack {
|
||||
case .headerFieldReceived:
|
||||
if let parserBuffer = self.parserBuffer {
|
||||
self.lastHeaderName = String(data: parserBuffer, encoding: .utf8)
|
||||
self.parserBuffer = nil
|
||||
} else {
|
||||
print("Missing parserBuffer after \(lastCallBack)")
|
||||
}
|
||||
case .headerValueReceived:
|
||||
if let parserBuffer = self.parserBuffer,
|
||||
let lastHeaderName = self.lastHeaderName,
|
||||
let headerValue = String(data: parserBuffer, encoding: .utf8) {
|
||||
self.parsedHeaders.append([HTTPHeaders.Name(lastHeaderName): headerValue])
|
||||
self.lastHeaderName = nil
|
||||
self.parserBuffer = nil
|
||||
} else {
|
||||
print("Missing parserBuffer after \(lastCallBack)")
|
||||
}
|
||||
case .headersCompleted:
|
||||
self.parserBuffer = nil
|
||||
|
||||
if !upgradeRequested {
|
||||
self.httpBodyProcessingCallback = self.handle(self.createRequest(), self)
|
||||
}
|
||||
case .urlReceived:
|
||||
if let parserBuffer = self.parserBuffer {
|
||||
//Under heaptrack, this may appear to leak via _CFGetTSDCreateIfNeeded,
|
||||
// apparently, that's because it triggers thread metadata to be created
|
||||
self.parsedURL = String(data: parserBuffer, encoding: .utf8)
|
||||
self.parserBuffer = nil
|
||||
} else {
|
||||
print("Missing parserBuffer after \(lastCallBack)")
|
||||
}
|
||||
case .idle:
|
||||
break
|
||||
case .messageBegan:
|
||||
break
|
||||
case .messageCompleted:
|
||||
break
|
||||
case .bodyReceived:
|
||||
break
|
||||
}
|
||||
lastCallBack = currentCallBack
|
||||
return true
|
||||
}
|
||||
|
||||
func messageBegan() -> Int32 {
|
||||
processCurrentCallback(.messageBegan)
|
||||
self.parserConnector?.responseBeginning()
|
||||
return 0
|
||||
}
|
||||
|
||||
func messageCompleted() -> Int32 {
|
||||
let didChangeState = processCurrentCallback(.messageCompleted)
|
||||
if let chunkHandler = self.httpBodyProcessingCallback, didChangeState {
|
||||
var dummy = false //We're sending `.end`, which means processing is stopping anyway, so the bool here is pointless
|
||||
switch chunkHandler {
|
||||
case .processBody(let handler):
|
||||
handler(.end, &dummy)
|
||||
case .discardBody:
|
||||
done()
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func headersCompleted(methodName: String,
|
||||
majorVersion: Int,
|
||||
minorVersion: Int,
|
||||
keepAlive: Bool,
|
||||
upgrade: Bool) -> Int32 {
|
||||
processCurrentCallback(.headersCompleted)
|
||||
self.parsedHTTPMethod = HTTPMethod(methodName)
|
||||
self.parsedHTTPVersion = HTTPVersion(major: majorVersion, minor: minorVersion)
|
||||
|
||||
//This needs to be set here and not messageCompleted if it's going to work here
|
||||
self.clientRequestedKeepAlive = keepAlive
|
||||
self.keepAliveUntil = Date(timeIntervalSinceNow: keepAliveTimeout).timeIntervalSinceReferenceDate
|
||||
self.upgradeRequested = upgrade
|
||||
return 0
|
||||
}
|
||||
|
||||
func headerFieldReceived(data: UnsafePointer<Int8>?, length: Int) -> Int32 {
|
||||
processCurrentCallback(.headerFieldReceived)
|
||||
guard let data = data else { return 0 }
|
||||
_parserBufferLock.wait()
|
||||
defer { _parserBufferLock.signal() }
|
||||
|
||||
data.withMemoryRebound(to: UInt8.self, capacity: length) { (ptr) -> Void in
|
||||
if var parserBuffer = parserBuffer {
|
||||
parserBuffer.append(ptr, count: length)
|
||||
} else {
|
||||
parserBuffer = Data(bytes: data, count: length)
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func headerValueReceived(data: UnsafePointer<Int8>?, length: Int) -> Int32 {
|
||||
processCurrentCallback(.headerValueReceived)
|
||||
guard let data = data else { return 0 }
|
||||
_parserBufferLock.wait()
|
||||
defer { _parserBufferLock.signal() }
|
||||
|
||||
data.withMemoryRebound(to: UInt8.self, capacity: length) { (ptr) -> Void in
|
||||
if var parserBuffer = parserBuffer {
|
||||
parserBuffer.append(ptr, count: length)
|
||||
} else {
|
||||
parserBuffer = Data(bytes: data, count: length)
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func bodyReceived(data: UnsafePointer<Int8>?, length: Int) -> Int32 {
|
||||
processCurrentCallback(.bodyReceived)
|
||||
guard let data = data else { return 0 }
|
||||
if shouldStopProcessingBody {
|
||||
return 0
|
||||
}
|
||||
data.withMemoryRebound(to: UInt8.self, capacity: length) { (ptr) -> Void in
|
||||
#if swift(>=4.0)
|
||||
let buff = UnsafeRawBufferPointer(start: ptr, count: length)
|
||||
#else
|
||||
let buff = UnsafeBufferPointer<UInt8>(start: ptr, count: length)
|
||||
#endif
|
||||
let chunk = DispatchData(bytes: buff)
|
||||
if let chunkHandler = self.httpBodyProcessingCallback {
|
||||
switch chunkHandler {
|
||||
case .processBody(let handler):
|
||||
//OK, this sucks. We can't access the value of the `inout` inside this block
|
||||
// due to exclusivity. Which means that if we were to pass a local variable, we'd
|
||||
// have to put a semaphore or something up here to wait for the block to be done before
|
||||
// we could get its value and pass that on to the instance variable. So instead, we're
|
||||
// just passing in a pointer to the internal ivar. But that ivar can't be modified in
|
||||
// more than one place, so we have to put a semaphore around it to prevent that.
|
||||
_shouldStopProcessingBodyLock.wait()
|
||||
handler(.chunk(data: chunk, finishedProcessing: { self._shouldStopProcessingBodyLock.signal() }), &_shouldStopProcessingBody)
|
||||
case .discardBody:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func urlReceived(data: UnsafePointer<Int8>?, length: Int) -> Int32 {
|
||||
processCurrentCallback(.urlReceived)
|
||||
guard let data = data else { return 0 }
|
||||
_parserBufferLock.wait()
|
||||
defer { _parserBufferLock.signal() }
|
||||
|
||||
data.withMemoryRebound(to: UInt8.self, capacity: length) { (ptr) -> Void in
|
||||
if var parserBuffer = parserBuffer {
|
||||
parserBuffer.append(ptr, count: length)
|
||||
} else {
|
||||
parserBuffer = Data(bytes: data, count: length)
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
static func getSelf(parser: UnsafeMutablePointer<http_parser>?) -> StreamingParser? {
|
||||
guard let pointee = parser?.pointee.data else { return nil }
|
||||
return Unmanaged<StreamingParser>.fromOpaque(pointee).takeUnretainedValue()
|
||||
}
|
||||
|
||||
var headersWritten = false
|
||||
var isChunked = false
|
||||
|
||||
/// Create a `HTTPRequest` struct from the parsed information
|
||||
public func createRequest() -> HTTPRequest {
|
||||
return HTTPRequest(method: parsedHTTPMethod!,
|
||||
target: parsedURL!,
|
||||
httpVersion: parsedHTTPVersion!,
|
||||
headers: parsedHeaders)
|
||||
}
|
||||
|
||||
public func writeHeader(status: HTTPResponseStatus, headers: HTTPHeaders, completion: @escaping (Result) -> Void) {
|
||||
|
||||
guard !headersWritten else {
|
||||
return
|
||||
}
|
||||
|
||||
var header = "HTTP/1.1 \(status.code) \(status.reasonPhrase)\r\n"
|
||||
|
||||
let isInformational = status.class == .informational
|
||||
|
||||
var headers = headers
|
||||
if !isInformational {
|
||||
adjustHeaders(status: status, headers: &headers)
|
||||
}
|
||||
|
||||
for (key, value) in headers {
|
||||
// TODO encode value using [RFC5987]
|
||||
header += "\(key): \(value)\r\n"
|
||||
}
|
||||
header.append("\r\n")
|
||||
guard !abortCalled else {
|
||||
completion(.error(StreamingParserError.ConnectionAbortedError))
|
||||
return
|
||||
}
|
||||
|
||||
// FIXME headers are US-ASCII, anything else should be encoded using [RFC5987] some lines above
|
||||
// TODO use requested encoding if specified
|
||||
if let data = header.data(using: .utf8) {
|
||||
self.parserConnector?.queueSocketWrite(data, completion: completion)
|
||||
if !isInformational {
|
||||
headersWritten = true
|
||||
}
|
||||
} else {
|
||||
//TODO handle encoding error
|
||||
}
|
||||
}
|
||||
|
||||
func adjustHeaders(status: HTTPResponseStatus, headers: inout HTTPHeaders) {
|
||||
for header in status.suppressedHeaders {
|
||||
headers[header] = nil
|
||||
}
|
||||
|
||||
if headers[.contentLength] != nil {
|
||||
headers[.transferEncoding] = "identity"
|
||||
} else if parsedHTTPVersion! >= HTTPVersion(major: 1, minor: 1) {
|
||||
switch headers[.transferEncoding] {
|
||||
case .some("identity"): // identity without content-length
|
||||
clientRequestedKeepAlive = false
|
||||
case .some("chunked"):
|
||||
isChunked = true
|
||||
default:
|
||||
isChunked = true
|
||||
headers[.transferEncoding] = "chunked"
|
||||
}
|
||||
} else {
|
||||
// HTTP 1.0 does not support chunked
|
||||
clientRequestedKeepAlive = false
|
||||
headers[.transferEncoding] = nil
|
||||
}
|
||||
|
||||
if clientRequestedKeepAlive {
|
||||
headers[.connection] = "Keep-Alive"
|
||||
} else {
|
||||
headers[.connection] = "Close"
|
||||
}
|
||||
}
|
||||
|
||||
public func writeTrailer(_ trailers: HTTPHeaders, completion: @escaping (Result) -> Void) {
|
||||
fatalError("Not implemented")
|
||||
}
|
||||
|
||||
public func writeBody(_ data: UnsafeHTTPResponseBody, completion: @escaping (Result) -> Void) {
|
||||
guard headersWritten else {
|
||||
//TODO error or default headers?
|
||||
return
|
||||
}
|
||||
|
||||
guard data.withUnsafeBytes({ $0.count > 0 }) else {
|
||||
completion(.ok)
|
||||
return
|
||||
}
|
||||
|
||||
let dataToWrite: Data
|
||||
if isChunked {
|
||||
dataToWrite = data.withUnsafeBytes {
|
||||
let chunkStart = (String($0.count, radix: 16) + "\r\n").data(using: .utf8)!
|
||||
var dataToWrite = chunkStart
|
||||
dataToWrite.append(UnsafeBufferPointer(start: $0.baseAddress?.assumingMemoryBound(to: UInt8.self), count: $0.count))
|
||||
let chunkEnd = "\r\n".data(using: .utf8)!
|
||||
dataToWrite.append(chunkEnd)
|
||||
return dataToWrite
|
||||
}
|
||||
} else if let data = data as? Data {
|
||||
dataToWrite = data
|
||||
} else {
|
||||
dataToWrite = data.withUnsafeBytes { Data($0) }
|
||||
}
|
||||
|
||||
guard !abortCalled else {
|
||||
completion(.error(StreamingParserError.ConnectionAbortedError))
|
||||
return
|
||||
}
|
||||
|
||||
self.parserConnector?.queueSocketWrite(dataToWrite, completion: completion)
|
||||
}
|
||||
|
||||
public func done(completion: @escaping (Result) -> Void) {
|
||||
guard !abortCalled else {
|
||||
completion(.error(StreamingParserError.ConnectionAbortedError))
|
||||
return
|
||||
}
|
||||
if isChunked {
|
||||
let chunkTerminate = "0\r\n\r\n".data(using: .utf8)!
|
||||
self.parserConnector?.queueSocketWrite(chunkTerminate, completion: completion)
|
||||
}
|
||||
|
||||
self.parsedHTTPMethod = nil
|
||||
self.parsedURL = nil
|
||||
self.parsedHeaders = HTTPHeaders()
|
||||
self.lastHeaderName = nil
|
||||
_parserBufferLock.wait()
|
||||
self.parserBuffer = nil
|
||||
_parserBufferLock.signal()
|
||||
self.parsedHTTPMethod = nil
|
||||
self.parsedHTTPVersion = nil
|
||||
self.lastCallBack = .idle
|
||||
self.headersWritten = false
|
||||
self.httpBodyProcessingCallback = nil
|
||||
self.upgradeRequested = false
|
||||
self.shouldStopProcessingBody = false
|
||||
|
||||
//Note: This used to be passed into the completion block that `Result` used to have
|
||||
// But since that block was removed, we're calling it directly
|
||||
if self.clientRequestedKeepAlive {
|
||||
self.keepAliveUntil = Date(timeIntervalSinceNow: keepAliveTimeout).timeIntervalSinceReferenceDate
|
||||
guard !abortCalled else {
|
||||
completion(.error(StreamingParserError.ConnectionAbortedError))
|
||||
return
|
||||
}
|
||||
self.parserConnector?.responseComplete()
|
||||
} else {
|
||||
guard !abortCalled else {
|
||||
completion(.error(StreamingParserError.ConnectionAbortedError))
|
||||
return
|
||||
}
|
||||
self.parserConnector?.responseCompleteCloseWriter()
|
||||
}
|
||||
completion(.ok)
|
||||
}
|
||||
|
||||
public func abort() {
|
||||
abortCalled = true
|
||||
}
|
||||
|
||||
deinit {
|
||||
httpParser.data = nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Protocol implemented by the thing that sits in between us and the network layer
|
||||
/// :nodoc:
|
||||
public protocol ParserConnecting: class {
|
||||
/// Send data to the network do be written to the client
|
||||
func queueSocketWrite(_ from: Data, completion: @escaping (Result) -> Void)
|
||||
|
||||
/// Let the network know that a response has started to avoid closing a connection during a slow write
|
||||
func responseBeginning()
|
||||
|
||||
/// Let the network know that a response is complete, so it can be closed after timeout
|
||||
func responseComplete()
|
||||
|
||||
/// Let the network know that a response is complete and we're ready to close the connection
|
||||
func responseCompleteCloseWriter()
|
||||
|
||||
/// Used to let the network know we're ready to close the connection
|
||||
func closeWriter()
|
||||
}
|
||||
|
||||
/// Delegate that can tell us how many connections are in-flight so we can set the Keep-Alive header
|
||||
/// to the correct number of available connections
|
||||
/// :nodoc:
|
||||
public protocol CurrentConnectionCounting: class {
|
||||
/// Current number of active connections
|
||||
var connectionCount: Int { get }
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
/// Version number of the HTTP Protocol
|
||||
public struct HTTPVersion {
|
||||
/// Major version component.
|
||||
public private(set) var major: Int
|
||||
/// Minor version component.
|
||||
public private(set) var minor: Int
|
||||
|
||||
/// Creates an HTTP version.
|
||||
public init(major: Int, minor: Int) {
|
||||
self.major = major
|
||||
self.minor = minor
|
||||
}
|
||||
}
|
||||
|
||||
extension HTTPVersion: Hashable {
|
||||
/// :nodoc:
|
||||
public var hashValue: Int {
|
||||
return (major << 8) | minor
|
||||
}
|
||||
}
|
||||
|
||||
extension HTTPVersion {
|
||||
/// :nodoc:
|
||||
public static func == (lhs: HTTPVersion, rhs: HTTPVersion) -> Bool {
|
||||
return lhs.major == rhs.major && lhs.minor == rhs.minor
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public static func ~= (match: HTTPVersion, version: HTTPVersion) -> Bool {
|
||||
return match == version
|
||||
}
|
||||
}
|
||||
|
||||
extension HTTPVersion: Comparable {
|
||||
/// :nodoc:
|
||||
public static func < (lhs: HTTPVersion, rhs: HTTPVersion) -> Bool {
|
||||
if lhs.major != rhs.major {
|
||||
return lhs.major < rhs.major
|
||||
} else {
|
||||
return lhs.minor < rhs.minor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension HTTPVersion: CustomStringConvertible {
|
||||
/// :nodoc:
|
||||
public var description: String {
|
||||
return "HTTP/\(major).\(minor)"
|
||||
}
|
||||
}
|
||||
@@ -1,361 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Dispatch
|
||||
import ServerSecurity
|
||||
|
||||
///:nodoc:
|
||||
public enum PoCSocketError: Error {
|
||||
case SocketOSError(errno: Int32)
|
||||
case InvalidSocketError
|
||||
case InvalidReadLengthError
|
||||
case InvalidWriteLengthError
|
||||
case InvalidBufferError
|
||||
}
|
||||
|
||||
/// Simple Wrapper around the `socket(2)` functions we need for Proof of Concept testing
|
||||
/// Intentionally a thin layer over `recv(2)`/`send(2)` so uses the same argument types.
|
||||
/// Note that no method names here are the same as any system call names.
|
||||
/// This is because we expect the caller might need functionality we haven't implemented here.
|
||||
internal class PoCSocket: ConnectionDelegate {
|
||||
|
||||
/// hold the file descriptor for the socket supplied by the OS. `-1` is invalid socket
|
||||
internal var socketfd: Int32 = -1
|
||||
|
||||
/// The TCP port the server is actually listening on. Set after system call completes
|
||||
internal var listeningPort: Int32 = -1
|
||||
|
||||
/// Track state between `listen(2)` and `shutdown(2)`
|
||||
private let _isListeningLock = DispatchSemaphore(value: 1)
|
||||
private var _isListening: Bool = false
|
||||
internal private(set) var isListening: Bool {
|
||||
get {
|
||||
_isListeningLock.wait()
|
||||
defer {
|
||||
_isListeningLock.signal()
|
||||
}
|
||||
return _isListening
|
||||
}
|
||||
set {
|
||||
_isListeningLock.wait()
|
||||
defer {
|
||||
_isListeningLock.signal()
|
||||
}
|
||||
_isListening = newValue
|
||||
}
|
||||
}
|
||||
|
||||
/// Track state between `accept(2)/bind(2)` and `close(2)`
|
||||
private let _isConnectedLock = DispatchSemaphore(value: 1)
|
||||
private var _isConnected: Bool = false
|
||||
internal private(set) var isConnected: Bool {
|
||||
get {
|
||||
_isConnectedLock.wait()
|
||||
defer {
|
||||
_isConnectedLock.signal()
|
||||
}
|
||||
return _isConnected
|
||||
}
|
||||
set {
|
||||
_isConnectedLock.wait()
|
||||
defer {
|
||||
_isConnectedLock.signal()
|
||||
}
|
||||
_isConnected = newValue
|
||||
}
|
||||
}
|
||||
|
||||
/// track whether a shutdown is in progress so we can suppress error messages
|
||||
private let _isShuttingDownLock = DispatchSemaphore(value: 1)
|
||||
private var _isShuttingDown: Bool = false
|
||||
private var isShuttingDown: Bool {
|
||||
get {
|
||||
_isShuttingDownLock.wait()
|
||||
defer {
|
||||
_isShuttingDownLock.signal()
|
||||
}
|
||||
return _isShuttingDown
|
||||
}
|
||||
set {
|
||||
_isShuttingDownLock.wait()
|
||||
defer {
|
||||
_isShuttingDownLock.signal()
|
||||
}
|
||||
_isShuttingDown = newValue
|
||||
}
|
||||
}
|
||||
|
||||
/// Delegate that provides the TLS implementation
|
||||
public var TLSdelegate: TLSServiceDelegate? = nil
|
||||
/// Return the file descriptor as a connection endpoint for ConnectionDelegate.
|
||||
public var endpoint: ConnectionType {
|
||||
get {
|
||||
return ConnectionType.socket(self.socketfd)
|
||||
}
|
||||
}
|
||||
|
||||
/// track whether a the socket has already been closed.
|
||||
private let _hasClosedLock = DispatchSemaphore(value: 1)
|
||||
private var _hasClosed: Bool = false
|
||||
private var hasClosed: Bool {
|
||||
get {
|
||||
_hasClosedLock.wait()
|
||||
defer {
|
||||
_hasClosedLock.signal()
|
||||
}
|
||||
return _hasClosed
|
||||
}
|
||||
set {
|
||||
_hasClosedLock.wait()
|
||||
defer {
|
||||
_hasClosedLock.signal()
|
||||
}
|
||||
_hasClosed = newValue
|
||||
}
|
||||
}
|
||||
|
||||
/// Call recv(2) with buffer allocated by our caller and return the output
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - readBuffer: Buffer to read into. Note this needs to be `inout` because we're modfying it and we want Swift4+'s ownership checks to make sure no one else is at the same time
|
||||
/// - maxLength: Max length that can be read. Buffer *must* be at least this big!!!
|
||||
/// - Returns: Number of bytes read or -1 on failure as per `recv(2)`
|
||||
/// - Throws: PoCSocketError if sanity checks fail
|
||||
internal func socketRead(into readBuffer: inout UnsafeMutablePointer<Int8>, maxLength: Int) throws -> Int {
|
||||
if maxLength <= 0 || maxLength > Int(Int32.max) {
|
||||
throw PoCSocketError.InvalidReadLengthError
|
||||
}
|
||||
if socketfd <= 0 {
|
||||
throw PoCSocketError.InvalidSocketError
|
||||
}
|
||||
|
||||
//Make sure no one passed a nil pointer to us
|
||||
let readBufferPointer: UnsafeMutablePointer<Int8>! = readBuffer
|
||||
if readBufferPointer == nil {
|
||||
throw PoCSocketError.InvalidBufferError
|
||||
}
|
||||
|
||||
//Make sure data isn't re-used
|
||||
readBuffer.initialize(to: 0x0, count: maxLength)
|
||||
|
||||
let read: Int
|
||||
if let tls = self.TLSdelegate {
|
||||
// HTTPS
|
||||
read = try tls.willReceive(into: readBuffer, bufSize: maxLength)
|
||||
} else {
|
||||
// HTTP
|
||||
read = recv(self.socketfd, readBuffer, maxLength, Int32(0))
|
||||
}
|
||||
//Leave this as a local variable to facilitate Setting a Watchpoint in lldb
|
||||
return read
|
||||
}
|
||||
|
||||
/// Pass buffer passed into to us into send(2).
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - buffer: buffer containing data to write.
|
||||
/// - bufSize: number of bytes to write. Buffer must be this long
|
||||
/// - Returns: number of bytes written or -1. See `send(2)`
|
||||
/// - Throws: PoCSocketError if sanity checks fail
|
||||
@discardableResult internal func socketWrite(from buffer: UnsafeRawPointer, bufSize: Int) throws -> Int {
|
||||
if socketfd <= 0 {
|
||||
throw PoCSocketError.InvalidSocketError
|
||||
}
|
||||
if bufSize < 0 || bufSize > Int(Int32.max) {
|
||||
throw PoCSocketError.InvalidWriteLengthError
|
||||
}
|
||||
|
||||
// Make sure we weren't handed a nil buffer
|
||||
let writeBufferPointer: UnsafeRawPointer! = buffer
|
||||
if writeBufferPointer == nil {
|
||||
throw PoCSocketError.InvalidBufferError
|
||||
}
|
||||
|
||||
let sent: Int
|
||||
if let tls = self.TLSdelegate {
|
||||
// HTTPS
|
||||
sent = try tls.willSend(buffer: buffer, bufSize: Int(bufSize))
|
||||
} else {
|
||||
// HTTP
|
||||
sent = send(self.socketfd, buffer, Int(bufSize), Int32(0))
|
||||
}
|
||||
//Leave this as a local variable to facilitate Setting a Watchpoint in lldb
|
||||
return sent
|
||||
}
|
||||
|
||||
/// Calls `shutdown(2)` and `close(2)` on a socket
|
||||
internal func shutdownAndClose() {
|
||||
self.isShuttingDown = true
|
||||
if let tls = self.TLSdelegate {
|
||||
tls.willDestroy()
|
||||
}
|
||||
if socketfd < 1 {
|
||||
//Nothing to do. Maybe it was closed already
|
||||
return
|
||||
}
|
||||
if hasClosed {
|
||||
//Nothing to do. It was closed already
|
||||
return
|
||||
}
|
||||
if self.isListening || self.isConnected {
|
||||
_ = shutdown(self.socketfd, Int32(SHUT_RDWR))
|
||||
self.isListening = false
|
||||
}
|
||||
self.isConnected = false
|
||||
close(self.socketfd)
|
||||
self.hasClosed = true
|
||||
}
|
||||
|
||||
/// Thin wrapper around `accept(2)`
|
||||
///
|
||||
/// - Returns: PoCSocket object for newly connected socket or nil if we've been told to shutdown
|
||||
/// - Throws: PoCSocketError on sanity check fails or if accept fails after several retries
|
||||
internal func acceptClientConnection() throws -> PoCSocket? {
|
||||
if socketfd <= 0 || !isListening {
|
||||
throw PoCSocketError.InvalidSocketError
|
||||
}
|
||||
|
||||
let retVal = PoCSocket()
|
||||
|
||||
var maxRetryCount = 100
|
||||
|
||||
var acceptFD: Int32 = -1
|
||||
repeat {
|
||||
var acceptAddr = sockaddr_in()
|
||||
var addrSize = socklen_t(MemoryLayout<sockaddr_in>.size)
|
||||
|
||||
acceptFD = withUnsafeMutablePointer(to: &acceptAddr) { pointer in
|
||||
return accept(self.socketfd, UnsafeMutableRawPointer(pointer).assumingMemoryBound(to: sockaddr.self), &addrSize)
|
||||
}
|
||||
if acceptFD < 0 && errno != EINTR {
|
||||
//fail
|
||||
if (isShuttingDown) {
|
||||
return nil
|
||||
}
|
||||
maxRetryCount = maxRetryCount - 1
|
||||
print("Could not accept on socket \(socketfd). Error is \(errno). Will retry.")
|
||||
}
|
||||
}
|
||||
while acceptFD < 0 && maxRetryCount > 0
|
||||
|
||||
if acceptFD < 0 {
|
||||
throw PoCSocketError.SocketOSError(errno: errno)
|
||||
}
|
||||
|
||||
retVal.isConnected = true
|
||||
retVal.socketfd = acceptFD
|
||||
|
||||
// TLS delegate does post accept handling and verification
|
||||
if let tls = self.TLSdelegate {
|
||||
try tls.didAccept(connection: retVal)
|
||||
}
|
||||
|
||||
return retVal
|
||||
}
|
||||
|
||||
/// call `bind(2)` and `listen(2)`
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - port: `sin_port` value, see `bind(2)`
|
||||
/// - maxBacklogSize: backlog argument to `listen(2)`
|
||||
/// - Throws: PoCSocketError
|
||||
internal func bindAndListen(on port: Int = 0, maxBacklogSize: Int32 = 100) throws {
|
||||
#if os(Linux)
|
||||
socketfd = socket(Int32(AF_INET), Int32(SOCK_STREAM.rawValue), Int32(IPPROTO_TCP))
|
||||
#else
|
||||
socketfd = socket(Int32(AF_INET), Int32(SOCK_STREAM), Int32(IPPROTO_TCP))
|
||||
#endif
|
||||
|
||||
if socketfd <= 0 {
|
||||
throw PoCSocketError.InvalidSocketError
|
||||
|
||||
}
|
||||
// Initialize delegate
|
||||
if let tls = self.TLSdelegate {
|
||||
try tls.didCreateServer()
|
||||
}
|
||||
|
||||
var on: Int32 = 1
|
||||
// Allow address reuse
|
||||
if setsockopt(self.socketfd, SOL_SOCKET, SO_REUSEADDR, &on, socklen_t(MemoryLayout<Int32>.size)) < 0 {
|
||||
throw PoCSocketError.SocketOSError(errno: errno)
|
||||
}
|
||||
|
||||
// Allow port reuse
|
||||
if setsockopt(self.socketfd, SOL_SOCKET, SO_REUSEPORT, &on, socklen_t(MemoryLayout<Int32>.size)) < 0 {
|
||||
throw PoCSocketError.SocketOSError(errno: errno)
|
||||
}
|
||||
|
||||
#if os(Linux)
|
||||
var addr = sockaddr_in(
|
||||
sin_family: sa_family_t(AF_INET),
|
||||
sin_port: htons(UInt16(port)),
|
||||
sin_addr: in_addr(s_addr: in_addr_t(0)),
|
||||
sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
|
||||
#else
|
||||
var addr = sockaddr_in(
|
||||
sin_len: UInt8(MemoryLayout<sockaddr_in>.stride),
|
||||
sin_family: UInt8(AF_INET),
|
||||
sin_port: (Int(OSHostByteOrder()) != OSLittleEndian ? UInt16(port) : _OSSwapInt16(UInt16(port))),
|
||||
sin_addr: in_addr(s_addr: in_addr_t(0)),
|
||||
sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
|
||||
#endif
|
||||
|
||||
_ = withUnsafePointer(to: &addr) {
|
||||
bind(self.socketfd, UnsafePointer<sockaddr>(OpaquePointer($0)), socklen_t(MemoryLayout<sockaddr_in>.size))
|
||||
}
|
||||
|
||||
_ = listen(self.socketfd, maxBacklogSize)
|
||||
|
||||
isListening = true
|
||||
|
||||
var addr_in = sockaddr_in()
|
||||
|
||||
listeningPort = try withUnsafePointer(to: &addr_in) { pointer in
|
||||
var len = socklen_t(MemoryLayout<sockaddr_in>.size)
|
||||
if getsockname(socketfd, UnsafeMutablePointer(OpaquePointer(pointer)), &len) != 0 {
|
||||
throw PoCSocketError.SocketOSError(errno: errno)
|
||||
}
|
||||
#if os(Linux)
|
||||
return Int32(ntohs(addr_in.sin_port))
|
||||
#else
|
||||
return Int32(Int(OSHostByteOrder()) != OSLittleEndian ? addr_in.sin_port.littleEndian : addr_in.sin_port.bigEndian)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// Check to see if socket is being used
|
||||
///
|
||||
/// - Returns: whether socket is listening or connected
|
||||
internal func isOpen() -> Bool {
|
||||
return isListening || isConnected
|
||||
}
|
||||
|
||||
/// Sets the socket to Blocking or non-blocking mode.
|
||||
///
|
||||
/// - Parameter mode: true for blocking, false for nonBlocking
|
||||
/// - Returns: `fcntl(2)` flags
|
||||
/// - Throws: PoCSocketError if `fcntl` fails
|
||||
@discardableResult internal func setBlocking(mode: Bool) throws -> Int32 {
|
||||
let flags = fcntl(self.socketfd, F_GETFL)
|
||||
if flags < 0 {
|
||||
//Failed
|
||||
throw PoCSocketError.SocketOSError(errno: errno)
|
||||
}
|
||||
|
||||
let newFlags = mode ? flags & ~O_NONBLOCK : flags | O_NONBLOCK
|
||||
|
||||
let result = fcntl(self.socketfd, F_SETFL, newFlags)
|
||||
if result < 0 {
|
||||
//Failed
|
||||
throw PoCSocketError.SocketOSError(errno: errno)
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -1,393 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Dispatch
|
||||
import ServerSecurity
|
||||
|
||||
///:nodoc:
|
||||
public class PoCSocketConnectionListener: ParserConnecting {
|
||||
|
||||
/// socket(2) wrapper object
|
||||
var socket: PoCSocket?
|
||||
|
||||
/// ivar for the thing that manages the CHTTP Parser
|
||||
var parser: StreamingParser?
|
||||
|
||||
/// Save the socket file descriptor so we can loook at it for debugging purposes
|
||||
var socketFD: Int32
|
||||
///Flag to track whether we've been told to shutdown or not (with lock)
|
||||
private let _shouldShutdownLock = DispatchSemaphore(value: 1)
|
||||
private var _shouldShutdown: Bool = false
|
||||
var shouldShutdown: Bool {
|
||||
get {
|
||||
_shouldShutdownLock.wait()
|
||||
defer {
|
||||
_shouldShutdownLock.signal()
|
||||
}
|
||||
return _shouldShutdown
|
||||
}
|
||||
set {
|
||||
_shouldShutdownLock.wait()
|
||||
defer {
|
||||
_shouldShutdownLock.signal()
|
||||
}
|
||||
_shouldShutdown = newValue
|
||||
}
|
||||
}
|
||||
|
||||
/// Queues for managing access to the socket without blocking the world
|
||||
let socketReaderQueue: DispatchQueue
|
||||
let socketWriterQueue: DispatchQueue
|
||||
|
||||
/// Event handler for reading from the socket
|
||||
private var readerSource: DispatchSourceRead?
|
||||
|
||||
/// Flag to track whether we're in the middle of a response or not (with lock)
|
||||
private let _responseCompletedLock = DispatchSemaphore(value: 1)
|
||||
private var _responseCompleted: Bool = false
|
||||
var responseCompleted: Bool {
|
||||
get {
|
||||
_responseCompletedLock.wait()
|
||||
defer {
|
||||
_responseCompletedLock.signal()
|
||||
}
|
||||
return _responseCompleted
|
||||
}
|
||||
set {
|
||||
_responseCompletedLock.wait()
|
||||
defer {
|
||||
_responseCompletedLock.signal()
|
||||
}
|
||||
_responseCompleted = newValue
|
||||
}
|
||||
}
|
||||
|
||||
/// Flag to track whether we've received a socket error or not (with lock)
|
||||
private let _errorOccurredLock = DispatchSemaphore(value: 1)
|
||||
private var _errorOccurred: Bool = false
|
||||
var errorOccurred: Bool {
|
||||
get {
|
||||
_errorOccurredLock.wait()
|
||||
defer {
|
||||
_errorOccurredLock.signal()
|
||||
}
|
||||
return _errorOccurred
|
||||
}
|
||||
set {
|
||||
_errorOccurredLock.wait()
|
||||
defer {
|
||||
_errorOccurredLock.signal()
|
||||
}
|
||||
_errorOccurred = newValue
|
||||
}
|
||||
}
|
||||
|
||||
///Flag to track whether we've already called cleanup or not (with lock)
|
||||
private let _cleanupCalledLock = DispatchSemaphore(value: 1)
|
||||
private var _cleanupCalled: Bool = false
|
||||
var cleanupCalled: Bool {
|
||||
get {
|
||||
_cleanupCalledLock.wait()
|
||||
defer {
|
||||
_cleanupCalledLock.signal()
|
||||
}
|
||||
return _cleanupCalled
|
||||
}
|
||||
set {
|
||||
_cleanupCalledLock.wait()
|
||||
defer {
|
||||
_cleanupCalledLock.signal()
|
||||
}
|
||||
_cleanupCalled = newValue
|
||||
}
|
||||
}
|
||||
|
||||
/// Largest number of bytes we're willing to allocate for a Read
|
||||
/// it's an anti-heartbleed-type paranoia check
|
||||
private var maxReadLength: Int = 1048576
|
||||
|
||||
/// initializer
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - socket: thin PoCSocket wrapper around system calls
|
||||
/// - parser: Manager of the CHTTPParser library
|
||||
internal init(socket: PoCSocket, parser: StreamingParser, readQueue: DispatchQueue, writeQueue: DispatchQueue, maxReadLength: Int = 0) {
|
||||
self.socket = socket
|
||||
socketFD = socket.socketfd
|
||||
socketReaderQueue = readQueue
|
||||
socketWriterQueue = writeQueue
|
||||
self.parser = parser
|
||||
parser.parserConnector = self
|
||||
if maxReadLength > 0 {
|
||||
self.maxReadLength = maxReadLength
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if socket is still open. Used to decide whether it should be closed/pruned after timeout
|
||||
public var isOpen: Bool {
|
||||
return self.socket?.isOpen() ?? false
|
||||
}
|
||||
|
||||
/// Close the socket and free up memory unless we're in the middle of a request
|
||||
func close() {
|
||||
self.shouldShutdown = true
|
||||
|
||||
if !self.responseCompleted && !self.errorOccurred {
|
||||
return
|
||||
}
|
||||
if (self.socket?.socketfd ?? -1) > 0 {
|
||||
self.socket?.shutdownAndClose()
|
||||
}
|
||||
|
||||
// In a perfect world, we wouldn't have to clean this all up explicitly,
|
||||
// but KDE/heaptrack informs us we're in far from a perfect world
|
||||
|
||||
if !(self.readerSource?.isCancelled ?? true) {
|
||||
/*
|
||||
OK, so later macOS wants `cancel()` to be called from inside the readerSource,
|
||||
otherwise, there's a very intermittent thread-dependent crash, (ask me how I know)
|
||||
so in that case, we set a Bool variable and call `activate()`. Older macOS doesn't
|
||||
have `activate()` so we call back to calling `cancel()` directly.
|
||||
|
||||
Linux *DOES* have activate(), but it doesn't seem to do anything at present, so we call `cancel()`
|
||||
directly in that case, too (Although I suspect that might need to change in future releases).
|
||||
*/
|
||||
#if os(Linux)
|
||||
// Call Cancel directory on Linux
|
||||
self.readerSource?.cancel()
|
||||
self.cleanup()
|
||||
#else
|
||||
if #available(OSX 10.12, *) {
|
||||
//Set Flag and Activate the readerSource so it can run `cancel()` for us
|
||||
self.shouldShutdown = true
|
||||
self.readerSource?.activate()
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
self.readerSource?.cancel()
|
||||
self.cleanup()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// Called by the parser to let us know that it's done with this socket
|
||||
public func closeWriter() {
|
||||
self.socketWriterQueue.async { [weak self] in
|
||||
if self?.readerSource?.isCancelled ?? true {
|
||||
self?.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if the socket is idle, and if so, call close()
|
||||
func closeIfIdleSocket() {
|
||||
if !self.responseCompleted {
|
||||
// We're in the middle of a connection - we're not idle
|
||||
return
|
||||
}
|
||||
let now = Date().timeIntervalSinceReferenceDate
|
||||
if let keepAliveUntil = parser?.keepAliveUntil, now >= keepAliveUntil {
|
||||
print("Closing idle socket \(socketFD)")
|
||||
close()
|
||||
}
|
||||
}
|
||||
|
||||
func cleanup() {
|
||||
guard !cleanupCalled else {
|
||||
// This prevents a rare crash (~1 in 300,000) where cleanup is called from both reader and writer
|
||||
// queues simultaneously
|
||||
return
|
||||
}
|
||||
|
||||
//allow for memory to be reclaimed
|
||||
if let strongReaderSource = self.readerSource {
|
||||
strongReaderSource.setEventHandler(handler: nil)
|
||||
strongReaderSource.setCancelHandler(handler: nil)
|
||||
}
|
||||
if let strongParser = self.parser {
|
||||
strongParser.parserConnector = nil
|
||||
}
|
||||
|
||||
cleanupCalled = true
|
||||
}
|
||||
|
||||
/// Called by the parser to let us know that a response has started being created
|
||||
public func responseBeginning() {
|
||||
self.responseCompleted = false
|
||||
}
|
||||
|
||||
/// Called by the parser to let us know that a response is complete, and we can close after timeout
|
||||
public func responseComplete() {
|
||||
self.responseCompleted = true
|
||||
self.socketWriterQueue.async { [weak self] in
|
||||
if self?.readerSource?.isCancelled ?? true {
|
||||
self?.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Called by the parser to let us know that a response is complete and we should close the socket
|
||||
public func responseCompleteCloseWriter() {
|
||||
self.responseCompleted = true
|
||||
self.socketWriterQueue.async { [weak self] in
|
||||
self?.close()
|
||||
}
|
||||
}
|
||||
|
||||
/// Starts reading from the socket and feeding that data to the parser
|
||||
public func process() {
|
||||
let tempReaderSource: DispatchSourceRead
|
||||
// Make sure we have a socket here. Don't use guard so that
|
||||
// we don't encourage strongSocket to be used in the
|
||||
// event handler, which could cause a leak
|
||||
if let strongSocket = socket {
|
||||
do {
|
||||
try strongSocket.setBlocking(mode: true)
|
||||
tempReaderSource = DispatchSource.makeReadSource(fileDescriptor: strongSocket.socketfd,
|
||||
queue: socketReaderQueue)
|
||||
self.readerSource = tempReaderSource
|
||||
} catch {
|
||||
print("Socket cannot be set to Blocking in process(): \(error)")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
print("Socket is nil in process()")
|
||||
return
|
||||
}
|
||||
|
||||
tempReaderSource.setEventHandler { [weak self] in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
guard strongSelf.socket?.socketfd ?? -1 > 0 else {
|
||||
strongSelf.readerSource?.cancel()
|
||||
strongSelf.cleanup()
|
||||
return
|
||||
}
|
||||
guard !strongSelf.shouldShutdown else {
|
||||
strongSelf.readerSource?.cancel()
|
||||
strongSelf.cleanup()
|
||||
return
|
||||
}
|
||||
|
||||
if let strongSocket = strongSelf.socket {
|
||||
var length = 1 //initial value
|
||||
do {
|
||||
if strongSocket.socketfd > 0 {
|
||||
var maxLength: Int = Int(strongSelf.readerSource?.data ?? 0)
|
||||
if (maxLength > strongSelf.maxReadLength) || (maxLength <= 0) {
|
||||
maxLength = strongSelf.maxReadLength
|
||||
}
|
||||
// make sure we read all data buffered by TLS layer
|
||||
if (strongSocket.TLSdelegate != nil && (maxLength < TLSConstants.maxTLSRecordLength)) {
|
||||
maxLength = TLSConstants.maxTLSRecordLength
|
||||
}
|
||||
var readBuffer: UnsafeMutablePointer<Int8> = UnsafeMutablePointer<Int8>.allocate(capacity: maxLength)
|
||||
length = try strongSocket.socketRead(into: &readBuffer, maxLength:maxLength)
|
||||
if length > 0 {
|
||||
strongSelf.responseCompleted = false
|
||||
|
||||
let data = Data(bytes: readBuffer, count: length)
|
||||
let numberParsed = strongSelf.parser?.readStream(data:data) ?? 0
|
||||
|
||||
defer {
|
||||
readBuffer.deallocate(capacity: maxLength)
|
||||
}
|
||||
|
||||
if numberParsed != data.count {
|
||||
print("Error: wrong number of bytes consumed by parser (\(numberParsed) instead of \(data.count)")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print("bad socket FD while reading")
|
||||
length = -1
|
||||
}
|
||||
} catch {
|
||||
//print("ReaderSource Event Error: \(error)")
|
||||
strongSelf.readerSource?.cancel()
|
||||
|
||||
strongSelf.errorOccurred = true
|
||||
strongSelf.close()
|
||||
}
|
||||
|
||||
if length == 0 {
|
||||
//print("ReaderSource Read count zero. Cancelling.")
|
||||
strongSelf.readerSource?.cancel()
|
||||
}
|
||||
if length < 0 {
|
||||
//print("ReaderSource Read count negative. Closing.")
|
||||
strongSelf.errorOccurred = true
|
||||
strongSelf.readerSource?.cancel()
|
||||
strongSelf.close()
|
||||
}
|
||||
} else {
|
||||
//print("ReaderSource Read found nil socket. Closing.")
|
||||
strongSelf.errorOccurred = true
|
||||
strongSelf.readerSource?.cancel()
|
||||
strongSelf.close()
|
||||
}
|
||||
}
|
||||
|
||||
tempReaderSource.setCancelHandler { [weak self] in
|
||||
if let strongSelf = self {
|
||||
strongSelf.close() //close if we can
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
self.readerSource?.resume()
|
||||
}
|
||||
|
||||
/// Called by the parser to give us data to send back out of the socket
|
||||
///
|
||||
/// - Parameter bytes: Data object to be queued to be written to the socket
|
||||
public func queueSocketWrite(_ bytes: Data, completion:@escaping (Result) -> Void) {
|
||||
self.socketWriterQueue.async { [weak self] in
|
||||
self?.write(bytes)
|
||||
completion(.ok)
|
||||
}
|
||||
}
|
||||
|
||||
/// Write data to a socket. Should be called in an `async` block on the `socketWriterQueue`
|
||||
///
|
||||
/// - Parameter data: data to be written
|
||||
public func write(_ data: Data) {
|
||||
do {
|
||||
var written: Int = 0
|
||||
var offset = 0
|
||||
|
||||
while written < data.count && !errorOccurred {
|
||||
try data.withUnsafeBytes { (ptr: UnsafePointer<UInt8>) in
|
||||
if let strongSocket = socket {
|
||||
let result = try strongSocket.socketWrite(from: ptr + offset, bufSize:
|
||||
data.count - offset)
|
||||
if result < 0 {
|
||||
//print("Received broken write socket indication")
|
||||
errorOccurred = true
|
||||
} else {
|
||||
written += result
|
||||
}
|
||||
} else {
|
||||
//print("Socket unexpectedly nil during write")
|
||||
errorOccurred = true
|
||||
}
|
||||
}
|
||||
offset = data.count - written
|
||||
}
|
||||
if errorOccurred {
|
||||
close()
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
print("Received write socket error: \(error)")
|
||||
errorOccurred = true
|
||||
close()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import Dispatch
|
||||
import Foundation
|
||||
import ServerSecurity
|
||||
import TLSService
|
||||
|
||||
// MARK: Server
|
||||
|
||||
/// An HTTP server that listens for connections on a TCP socket and spawns Listeners to handle them.
|
||||
///:nodoc:
|
||||
public class PoCSocketSimpleServer: CurrentConnectionCounting {
|
||||
/// PoCSocket to listen on for connections
|
||||
private let serverSocket: PoCSocket = PoCSocket()
|
||||
|
||||
/// Collection of listeners of sockets. Used to kill connections on timeout or shutdown
|
||||
private var connectionListenerList = ConnectionListenerCollection()
|
||||
|
||||
/// Timer that cleans up idle sockets on expire
|
||||
private let pruneSocketTimer: DispatchSourceTimer = DispatchSource.makeTimerSource(queue: DispatchQueue(label: "pruneSocketTimer"))
|
||||
|
||||
/// The port we're listening on. Used primarily to query a randomly assigned port during XCTests
|
||||
public var port: Int {
|
||||
return Int(serverSocket.listeningPort)
|
||||
}
|
||||
|
||||
/// Tuning parameter to set the number of queues
|
||||
private var queueMax: Int = 4 //sensible default
|
||||
|
||||
/// Tuning parameter to set the number of sockets we can accept at one time
|
||||
private var acceptMax: Int = 8 //sensible default
|
||||
|
||||
/// Used to stop `accept(2)`ing while shutdown in progress to avoid spurious logs
|
||||
private let _isShuttingDownLock = DispatchSemaphore(value: 1)
|
||||
private var _isShuttingDown: Bool = false
|
||||
var isShuttingDown: Bool {
|
||||
get {
|
||||
_isShuttingDownLock.wait()
|
||||
defer {
|
||||
_isShuttingDownLock.signal()
|
||||
}
|
||||
return _isShuttingDown
|
||||
}
|
||||
set {
|
||||
_isShuttingDownLock.wait()
|
||||
defer {
|
||||
_isShuttingDownLock.signal()
|
||||
}
|
||||
_isShuttingDown = newValue
|
||||
}
|
||||
}
|
||||
|
||||
/// Starts the server listening on a given port
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - port: TCP port. See listen(2)
|
||||
/// - handler: Function that creates the HTTP Response from the HTTP Request
|
||||
/// - Throws: Error (usually a socket error) generated
|
||||
public func start(port: Int = 0,
|
||||
queueCount: Int = 0,
|
||||
acceptCount: Int = 0,
|
||||
maxReadLength: Int = 1048576,
|
||||
keepAliveTimeout: Double = 5.0,
|
||||
tls: TLSConfiguration? = nil,
|
||||
handler: @escaping HTTPRequestHandler) throws {
|
||||
|
||||
// Don't let a signal generated by a broken socket kill the server
|
||||
signal(SIGPIPE, SIG_IGN)
|
||||
|
||||
if queueCount > 0 {
|
||||
queueMax = queueCount
|
||||
}
|
||||
if acceptCount > 0 {
|
||||
acceptMax = acceptCount
|
||||
}
|
||||
// Set up TLS
|
||||
if let tlsConfig = tls {
|
||||
let tlsService = try TLSService(usingConfiguration: tlsConfig)
|
||||
self.serverSocket.TLSdelegate = tlsService
|
||||
}
|
||||
try self.serverSocket.bindAndListen(on: port)
|
||||
|
||||
pruneSocketTimer.setEventHandler { [weak self] in
|
||||
self?.connectionListenerList.prune()
|
||||
}
|
||||
#if swift(>=4.0)
|
||||
pruneSocketTimer.schedule(deadline: .now() + keepAliveTimeout,
|
||||
repeating: .seconds(Int(keepAliveTimeout)))
|
||||
#else
|
||||
pruneSocketTimer.scheduleRepeating(deadline: .now() + keepAliveTimeout,
|
||||
interval: .seconds(Int(keepAliveTimeout)))
|
||||
#endif
|
||||
pruneSocketTimer.resume()
|
||||
|
||||
var readQueues = [DispatchQueue]()
|
||||
var writeQueues = [DispatchQueue]()
|
||||
let acceptQueue = DispatchQueue(label: "Accept Queue", qos: .default, attributes: .concurrent)
|
||||
|
||||
let acceptSemaphore = DispatchSemaphore.init(value: acceptMax)
|
||||
|
||||
for idx in 0..<queueMax {
|
||||
readQueues.append(DispatchQueue(label: "Read Queue \(idx)"))
|
||||
writeQueues.append(DispatchQueue(label: "Write Queue \(idx)"))
|
||||
}
|
||||
|
||||
print("Started server on port \(self.serverSocket.listeningPort) with \(self.queueMax) serial queues of each type and \(self.acceptMax) accept sockets")
|
||||
|
||||
var listenerCount = 0
|
||||
DispatchQueue.global().async {
|
||||
repeat {
|
||||
do {
|
||||
let acceptedClientSocket = try self.serverSocket.acceptClientConnection()
|
||||
guard let clientSocket = acceptedClientSocket else {
|
||||
if self.isShuttingDown {
|
||||
print("Received nil client socket - exiting accept loop")
|
||||
}
|
||||
break
|
||||
}
|
||||
let streamingParser = StreamingParser(handler: handler, connectionCounter: self, keepAliveTimeout: keepAliveTimeout)
|
||||
let readQueue = readQueues[listenerCount % self.queueMax]
|
||||
let writeQueue = writeQueues[listenerCount % self.queueMax]
|
||||
let listener = PoCSocketConnectionListener(socket: clientSocket, parser: streamingParser, readQueue: readQueue, writeQueue: writeQueue, maxReadLength: maxReadLength)
|
||||
listenerCount += 1
|
||||
acceptSemaphore.wait()
|
||||
acceptQueue.async { [weak listener] in
|
||||
listener?.process()
|
||||
acceptSemaphore.signal()
|
||||
}
|
||||
self.connectionListenerList.add(listener)
|
||||
} catch let error {
|
||||
print("Error accepting client connection: \(error)")
|
||||
}
|
||||
} while !self.isShuttingDown && self.serverSocket.isListening
|
||||
}
|
||||
}
|
||||
|
||||
/// Stop the server and close the sockets
|
||||
public func stop() {
|
||||
isShuttingDown = true
|
||||
connectionListenerList.closeAll()
|
||||
serverSocket.shutdownAndClose()
|
||||
}
|
||||
|
||||
/// Count the connections - can be used in XCTests
|
||||
public var connectionCount: Int {
|
||||
return connectionListenerList.count
|
||||
}
|
||||
}
|
||||
|
||||
/// Collection of ConnectionListeners, wrapped with weak references, so the memory can be freed when the socket closes
|
||||
class ConnectionListenerCollection {
|
||||
/// Weak wrapper class
|
||||
class WeakConnectionListener<T: AnyObject> {
|
||||
weak var value: T?
|
||||
init (_ value: T) {
|
||||
self.value = value
|
||||
}
|
||||
}
|
||||
|
||||
/// Lock around access to storage
|
||||
private let lock = DispatchSemaphore(value: 1)
|
||||
|
||||
/// Storage for weak connection listeners
|
||||
private var storage = [WeakConnectionListener<PoCSocketConnectionListener>]()
|
||||
|
||||
/// Add a new connection to the collection
|
||||
///
|
||||
/// - Parameter listener: socket manager object
|
||||
func add(_ listener: PoCSocketConnectionListener) {
|
||||
lock.wait()
|
||||
storage.append(WeakConnectionListener(listener))
|
||||
lock.signal()
|
||||
}
|
||||
|
||||
/// Used when shutting down the server to close all connections
|
||||
func closeAll() {
|
||||
lock.wait()
|
||||
storage.filter { $0.value != nil }.forEach { $0.value?.close() }
|
||||
lock.signal()
|
||||
}
|
||||
|
||||
/// Close any idle sockets and remove any weak pointers to closed (and freed) sockets from the collection
|
||||
func prune() {
|
||||
lock.wait()
|
||||
storage.filter { nil != $0.value }.forEach { $0.value?.closeIfIdleSocket() }
|
||||
storage = storage.filter { $0.value != nil }.filter { $0.value?.isOpen ?? false }
|
||||
lock.signal()
|
||||
}
|
||||
|
||||
/// Count of collections
|
||||
var count: Int {
|
||||
lock.wait()
|
||||
let count = storage.filter { $0.value != nil }.count
|
||||
lock.signal()
|
||||
return count
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPHeaders Struct Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Struct/HTTPHeaders" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPHeaders Struct Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPHeaders Struct Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPHeaders</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPHeaders</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>Representation of the HTTP headers associated with a <code><a href="../Structs/HTTPRequest.html">HTTPRequest</a></code> or <code><a href="../Structs/HTTPResponse.html">HTTPResponse</a></code>.
|
||||
Headers are subscriptable using case-insensitive comparison or provide <code>Name</code> constants. eg.</p>
|
||||
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">contentLength</span> <span class="o">=</span> <span class="n">headers</span><span class="p">[</span><span class="s">"content-length"</span><span class="p">]</span>
|
||||
</code></pre>
|
||||
|
||||
<p>or</p>
|
||||
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">contentLength</span> <span class="o">=</span> <span class="n">headers</span><span class="p">[</span><span class="o">.</span><span class="n">contentLength</span><span class="p">]</span>
|
||||
</code></pre>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPHeadersVACSayAC4NameV_SStG17dictionaryLiterald_tcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(dictionaryLiteral:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPHeadersVACSayAC4NameV_SStG17dictionaryLiterald_tcfc">init(dictionaryLiteral:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Creates HTTP headers.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">dictionaryLiteral</span><span class="p">:</span> <span class="p">(</span><span class="kt"><a href="../Structs/HTTPHeaders/Name.html">Name</a></span><span class="p">,</span> <span class="kt">String</span><span class="p">)</span><span class="o">...</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPHeadersV6appendyAC7LiteralVF"></a>
|
||||
<a name="//apple_ref/swift/Method/append(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPHeadersV6appendyAC7LiteralVF">append(_:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Appends a header to the headers</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">append</span><span class="p">(</span><span class="n">_</span> <span class="nv">literal</span><span class="p">:</span> <span class="kt">HTTPHeaders</span><span class="o">.</span><span class="kt">Literal</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPHeadersV7replaceyAC7LiteralVF"></a>
|
||||
<a name="//apple_ref/swift/Method/replace(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPHeadersV7replaceyAC7LiteralVF">replace(_:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Replaces a header in the headers</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">mutating</span> <span class="kd">func</span> <span class="nf">replace</span><span class="p">(</span><span class="n">_</span> <span class="nv">literal</span><span class="p">:</span> <span class="kt">HTTPHeaders</span><span class="o">.</span><span class="kt">Literal</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPHeadersV4NameV"></a>
|
||||
<a name="//apple_ref/swift/Struct/Name" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPHeadersV4NameV">Name</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Type used for the name of a HTTP header in the <code><a href="../Structs/HTTPHeaders.html">HTTPHeaders</a></code> storage.</p>
|
||||
|
||||
<a href="../Structs/HTTPHeaders/Name.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">Name</span><span class="p">:</span> <span class="kt">Hashable</span><span class="p">,</span> <span class="kt">ExpressibleByStringLiteral</span><span class="p">,</span> <span class="kt">CustomStringConvertible</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,272 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPRequest Struct Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Struct/HTTPRequest" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPRequest Struct Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPRequest Struct Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPRequest</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPRequest</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>A structure representing the headers from a HTTP request, without the body of the request.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPRequestV6methodAA10HTTPMethodVv"></a>
|
||||
<a name="//apple_ref/swift/Property/method" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPRequestV6methodAA10HTTPMethodVv">method</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>HTTP request method.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">method</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPMethod.html">HTTPMethod</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPRequestV6targetSSv"></a>
|
||||
<a name="//apple_ref/swift/Property/target" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPRequestV6targetSSv">target</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>HTTP request URI, eg. <q>/foo/bar?buz=qux</q></p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">target</span><span class="p">:</span> <span class="kt">String</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPRequestV11httpVersionAA11HTTPVersionVv"></a>
|
||||
<a name="//apple_ref/swift/Property/httpVersion" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPRequestV11httpVersionAA11HTTPVersionVv">httpVersion</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>HTTP request version</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">httpVersion</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPVersion.html">HTTPVersion</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPRequestV7headersAA11HTTPHeadersVv"></a>
|
||||
<a name="//apple_ref/swift/Property/headers" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPRequestV7headersAA11HTTPHeadersVv">headers</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>HTTP request headers</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">headers</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPHeaders.html">HTTPHeaders</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,245 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPResponse Struct Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Struct/HTTPResponse" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPResponse Struct Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPResponse Struct Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPResponse</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPResponse</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>A structure representing the headers for a HTTP response, without the body of the response.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP12HTTPResponseV11httpVersionAA11HTTPVersionVv"></a>
|
||||
<a name="//apple_ref/swift/Property/httpVersion" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP12HTTPResponseV11httpVersionAA11HTTPVersionVv">httpVersion</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>HTTP response version</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">httpVersion</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPVersion.html">HTTPVersion</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP12HTTPResponseV6statusAA0B6StatusVv"></a>
|
||||
<a name="//apple_ref/swift/Property/status" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP12HTTPResponseV6statusAA0B6StatusVv">status</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>HTTP response status</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">status</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP12HTTPResponseV7headersAA11HTTPHeadersVv"></a>
|
||||
<a name="//apple_ref/swift/Property/headers" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP12HTTPResponseV7headersAA11HTTPHeadersVv">headers</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>HTTP response headers</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">headers</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPHeaders.html">HTTPHeaders</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,351 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Class Enum Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../../js/jquery.min.js" defer></script>
|
||||
<script src="../../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../../js/lunr.min.js" defer></script>
|
||||
<script src="../../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Enum/Class" class="dashAnchor"></a>
|
||||
|
||||
<a title="Class Enum Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../../img/carat.png" />
|
||||
Class Enum Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>Class</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">Class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>The class of a <code><a href="../../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a></code> code</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<a href="https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml">https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml</a> for more information
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseStatusV5ClassO13informationalA2EmF"></a>
|
||||
<a name="//apple_ref/swift/Element/informational" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseStatusV5ClassO13informationalA2EmF">informational</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Informational: the request was received, and is continuing to be processed</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="n">informational</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseStatusV5ClassO10successfulA2EmF"></a>
|
||||
<a name="//apple_ref/swift/Element/successful" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseStatusV5ClassO10successfulA2EmF">successful</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Success: the action was successfully received, understood, and accepted</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="n">successful</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseStatusV5ClassO11redirectionA2EmF"></a>
|
||||
<a name="//apple_ref/swift/Element/redirection" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseStatusV5ClassO11redirectionA2EmF">redirection</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Redirection: further action must be taken in order to complete the request</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="n">redirection</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseStatusV5ClassO11clientErrorA2EmF"></a>
|
||||
<a name="//apple_ref/swift/Element/clientError" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseStatusV5ClassO11clientErrorA2EmF">clientError</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Client Error: the request contains bad syntax or cannot be fulfilled</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="n">clientError</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseStatusV5ClassO11serverErrorA2EmF"></a>
|
||||
<a name="//apple_ref/swift/Element/serverError" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseStatusV5ClassO11serverErrorA2EmF">serverError</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Server Error: the server failed to fulfill an apparently valid request</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="n">serverError</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseStatusV5ClassO07invalidC0A2EmF"></a>
|
||||
<a name="//apple_ref/swift/Element/invalidStatus" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseStatusV5ClassO07invalidC0A2EmF">invalidStatus</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Invalid: the code does not map to a well known status code class</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="n">invalidStatus</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,245 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPVersion Struct Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Struct/HTTPVersion" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPVersion Struct Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPVersion Struct Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPVersion</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPVersion</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>Version number of the HTTP Protocol</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPVersionV5majorSiv"></a>
|
||||
<a name="//apple_ref/swift/Property/major" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPVersionV5majorSiv">major</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Major version component.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">private(set)</span> <span class="k">var</span> <span class="nv">major</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPVersionV5minorSiv"></a>
|
||||
<a name="//apple_ref/swift/Property/minor" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPVersionV5minorSiv">minor</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Minor version component.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">private(set)</span> <span class="k">var</span> <span class="nv">minor</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPVersionVACSi5major_Si5minortcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(major:minor:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPVersionVACSi5major_Si5minortcfc">init(major:minor:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Creates an HTTP version.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">major</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span> <span class="nv">minor</span><span class="p">:</span> <span class="kt">Int</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -1,85 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
@testable import HTTP
|
||||
|
||||
class HeadersTests: XCTestCase {
|
||||
func testHeaders() {
|
||||
var headers: HTTPHeaders = [
|
||||
.accept: "text/html",
|
||||
"Accept": "application/xhtml+xml",
|
||||
"Accept": "application/xml;q=0.9",
|
||||
"accept": "image/webp",
|
||||
.accept: "*/*;q=0.8",
|
||||
"Accept-Language": "ru-RU,ru;q=0.8",
|
||||
.acceptLanguage: "en-US;q=0.6",
|
||||
"accept-language": "en;q=0.4",
|
||||
"Content-Length": "200",
|
||||
"Set-Cookie": "test1=0; expires=Tue, 21 Jun 2016 16:26:50 GMT; path=/; domain=.my.mail.ru",
|
||||
"Set-Cookie": "test2=0; expires=Tue, 21 Jun 2016 16:26:50 GMT; path=/; domain=.my.mail.ru",
|
||||
]
|
||||
|
||||
XCTAssertEqual(headers["Content-Length"], "200")
|
||||
XCTAssertEqual(headers["content-length"], "200")
|
||||
XCTAssertEqual(headers[.contentLength], "200")
|
||||
XCTAssertEqual(headers[.accept], "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
|
||||
XCTAssertEqual(headers[.acceptLanguage], "ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4")
|
||||
XCTAssertEqual(headers[.setCookie], "test1=0; expires=Tue, 21 Jun 2016 16:26:50 GMT; path=/; domain=.my.mail.ru")
|
||||
|
||||
XCTAssertEqual(headers[valuesFor: "Content-Length"], ["200"])
|
||||
XCTAssertEqual(headers[valuesFor: "content-length"], ["200"])
|
||||
XCTAssertEqual(headers[valuesFor: .contentLength], ["200"])
|
||||
XCTAssertEqual(headers[valuesFor: .accept], ["text/html", "application/xhtml+xml", "application/xml;q=0.9", "image/webp", "*/*;q=0.8"])
|
||||
XCTAssertEqual(headers[valuesFor: .setCookie], [
|
||||
"test1=0; expires=Tue, 21 Jun 2016 16:26:50 GMT; path=/; domain=.my.mail.ru",
|
||||
"test2=0; expires=Tue, 21 Jun 2016 16:26:50 GMT; path=/; domain=.my.mail.ru",
|
||||
])
|
||||
|
||||
headers = HTTPHeaders()
|
||||
let initialCount = headers.makeIterator().reduce(0) { (last, _) -> Int in return last + 1 }
|
||||
XCTAssertEqual(0, initialCount)
|
||||
|
||||
headers.append(["Test-Header": "Test Value"])
|
||||
let nextCount = headers.makeIterator().reduce(0) { (last, _) -> Int in return last + 1 }
|
||||
XCTAssertEqual(1, nextCount)
|
||||
|
||||
let testHeaderValueArray = headers[valuesFor: "test-header"]
|
||||
XCTAssertNotNil(testHeaderValueArray)
|
||||
XCTAssertEqual(1, testHeaderValueArray.count)
|
||||
XCTAssertEqual("Test Value", testHeaderValueArray.first ?? "Not Found")
|
||||
|
||||
headers.append(["Test-header": "Test Value 2"])
|
||||
let testHeaderValueArray2 = headers[valuesFor: "test-header"]
|
||||
XCTAssertNotNil(testHeaderValueArray2)
|
||||
XCTAssertEqual(2, testHeaderValueArray2.count)
|
||||
XCTAssertEqual("Test Value", testHeaderValueArray2.first ?? "Not Found")
|
||||
let testHeaderValueArray2Remainder = testHeaderValueArray2.dropFirst()
|
||||
XCTAssertEqual("Test Value 2", testHeaderValueArray2Remainder.first ?? "Not Found")
|
||||
|
||||
//This should overwrites, since the subscript is documented to use lowercase keys
|
||||
headers[valuesFor: "TEST-HEADER"]=["Test Value 3"]
|
||||
let testHeaderValueArray3 = headers[valuesFor: "test-header"]
|
||||
XCTAssertNotNil(testHeaderValueArray3)
|
||||
XCTAssertEqual(1, testHeaderValueArray3.count)
|
||||
|
||||
//Overwrite
|
||||
headers[valuesFor: "TEST-HEADER"]=["Test Value 4a", "Test Value 4b"]
|
||||
let testHeaderValueArray4 = headers[valuesFor: "test-header"]
|
||||
XCTAssertNotNil(testHeaderValueArray4)
|
||||
XCTAssertEqual(2, testHeaderValueArray4.count)
|
||||
XCTAssertEqual("Test Value 4a", testHeaderValueArray4.first ?? "Not Found")
|
||||
let testHeaderValueArray4Remainder = testHeaderValueArray4.dropFirst()
|
||||
XCTAssertEqual("Test Value 4b", testHeaderValueArray4Remainder.first ?? "Not Found")
|
||||
}
|
||||
|
||||
static var allTests = [
|
||||
("testHeaders", testHeaders),
|
||||
]
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import HTTP
|
||||
|
||||
/// Simple `HTTPRequestHandler` that prints "Hello, World" as per K&R
|
||||
class AbortAndSendHelloHandler: HTTPRequestHandling {
|
||||
|
||||
var chunkCalledCount = 0
|
||||
var chunkLength = 0
|
||||
|
||||
func handle(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
//Assume the router gave us the right request - at least for now
|
||||
response.writeHeader(status: .ok, headers: [.transferEncoding: "chunked", "X-foo": "bar"])
|
||||
return .processBody { (chunk, stop) in
|
||||
switch chunk {
|
||||
case .chunk(let data, let finishedProcessing):
|
||||
stop = true
|
||||
self.chunkCalledCount += 1
|
||||
self.chunkLength += data.count
|
||||
finishedProcessing()
|
||||
case .end:
|
||||
response.writeBody("Hello, World!")
|
||||
response.done()
|
||||
default:
|
||||
stop = true /* don't call us anymore */
|
||||
response.abort()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import HTTP
|
||||
|
||||
/// Simple `HTTPRequestHandler` that just echoes back whatever input it gets
|
||||
class EchoHandler: HTTPRequestHandling {
|
||||
func handle(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
//Assume the router gave us the right request - at least for now
|
||||
response.writeHeader(status: .ok, headers: ["Transfer-Encoding": "chunked", "X-foo": "bar"])
|
||||
return .processBody { (chunk, stop) in
|
||||
switch chunk {
|
||||
case .chunk(let data, let finishedProcessing):
|
||||
response.writeBody(data) { _ in
|
||||
finishedProcessing()
|
||||
}
|
||||
case .end:
|
||||
response.done()
|
||||
default:
|
||||
stop = true /* don't call us anymore */
|
||||
response.abort()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import HTTP
|
||||
|
||||
/// Simple `HTTPRequestHandler` that prints "Hello, World" as per K&R
|
||||
class HelloWorldHandler: HTTPRequestHandling {
|
||||
func handle(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
//Assume the router gave us the right request - at least for now
|
||||
response.writeHeader(status: .ok, headers: [.transferEncoding: "chunked", "X-foo": "bar"])
|
||||
return .processBody { (chunk, stop) in
|
||||
switch chunk {
|
||||
case .chunk(_, let finishedProcessing):
|
||||
finishedProcessing()
|
||||
case .end:
|
||||
response.writeBody("Hello, World!")
|
||||
response.done()
|
||||
default:
|
||||
stop = true /* don't call us anymore */
|
||||
response.abort()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import HTTP
|
||||
|
||||
/// `HelloWorldRequestHandler` that sets the keep alive header for XCTest purposes
|
||||
class HelloWorldKeepAliveHandler: HTTPRequestHandling {
|
||||
func handle(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
//Assume the router gave us the right request - at least for now
|
||||
response.writeHeader(status: .ok, headers: [
|
||||
"Transfer-Encoding": "chunked",
|
||||
"Connection": "Keep-Alive",
|
||||
"Keep-Alive": "timeout=5, max=10",
|
||||
])
|
||||
return .processBody { (chunk, stop) in
|
||||
switch chunk {
|
||||
case .chunk(_, let finishedProcessing):
|
||||
finishedProcessing()
|
||||
case .end:
|
||||
response.writeBody("Hello, World!")
|
||||
response.done()
|
||||
default:
|
||||
stop = true /* don't call us anymore */
|
||||
response.abort()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import HTTP
|
||||
|
||||
/// Simple `HTTPRequestHandler` that returns 200: OK without a body
|
||||
class OkHandler: HTTPRequestHandling {
|
||||
func handle(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
//Assume the router gave us the right request - at least for now
|
||||
response.writeHeader(status: .ok, headers: ["Transfer-Encoding": "chunked", "X-foo": "bar"])
|
||||
return .discardBody
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
/*
|
||||
This file isn't part of the API per se, but it's the easiest way to get started - just supply a completion block.
|
||||
It's also really handy for building up `HTTPRequestHandler`s to use when writing tests.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
import HTTP
|
||||
|
||||
/// Simple block-based wrapper to create a `HTTPRequestHandler`. Normally used during XCTests
|
||||
public class SimpleResponseCreator: HTTPRequestHandling {
|
||||
|
||||
public struct Response {
|
||||
public let status: HTTPResponseStatus
|
||||
public let headers: HTTPHeaders
|
||||
public let body: Data
|
||||
}
|
||||
|
||||
typealias SimpleHandlerBlock = (_ req: HTTPRequest, _ body: Data) -> Response
|
||||
let completionHandler: SimpleHandlerBlock
|
||||
|
||||
public init(completionHandler:@escaping (_ req: HTTPRequest, _ body: Data) -> Response) {
|
||||
self.completionHandler = completionHandler
|
||||
}
|
||||
|
||||
var buffer = Data()
|
||||
|
||||
public func handle(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
return .processBody { (chunk, stop) in
|
||||
switch chunk {
|
||||
case .chunk(let data, let finishedProcessing):
|
||||
if data.count > 0 {
|
||||
self.buffer.append(Data(data))
|
||||
}
|
||||
finishedProcessing()
|
||||
case .end:
|
||||
let responseResult = self.completionHandler(request, self.buffer)
|
||||
var headers = responseResult.headers
|
||||
headers.replace([.transferEncoding: "chunked"])
|
||||
response.writeHeader(status: responseResult.status, headers: headers)
|
||||
response.writeBody(responseResult.body) { _ in
|
||||
response.done()
|
||||
}
|
||||
default:
|
||||
stop = true /* don't call us anymore */
|
||||
response.abort()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Dispatch
|
||||
import HTTP
|
||||
|
||||
/// Acts as a fake/mock `HTTPServer` so we can write XCTests without having to worry about Sockets and such
|
||||
class TestResponseResolver: HTTPResponseWriter {
|
||||
let request: HTTPRequest
|
||||
let requestBody: DispatchData
|
||||
|
||||
var response: (status: HTTPResponseStatus, headers: HTTPHeaders)?
|
||||
var responseBody: HTTPResponseBody?
|
||||
|
||||
///Flag to track whether our handler has told us not to call it anymore
|
||||
private let _shouldStopProcessingBodyLock = DispatchSemaphore(value: 1)
|
||||
private var _shouldStopProcessingBody: Bool = false
|
||||
private var shouldStopProcessingBody: Bool {
|
||||
get {
|
||||
_shouldStopProcessingBodyLock.wait()
|
||||
defer {
|
||||
_shouldStopProcessingBodyLock.signal()
|
||||
}
|
||||
return _shouldStopProcessingBody
|
||||
}
|
||||
set {
|
||||
_shouldStopProcessingBodyLock.wait()
|
||||
defer {
|
||||
_shouldStopProcessingBodyLock.signal()
|
||||
}
|
||||
_shouldStopProcessingBody = newValue
|
||||
}
|
||||
}
|
||||
|
||||
init(request: HTTPRequest, requestBody: Data) {
|
||||
self.request = request
|
||||
self.requestBody = requestBody.withUnsafeBytes { (ptr: UnsafePointer<UInt8>) -> DispatchData in
|
||||
#if swift(>=4.0)
|
||||
return DispatchData(bytes: UnsafeRawBufferPointer(start: ptr, count: requestBody.count))
|
||||
#else
|
||||
return DispatchData(bytes: UnsafeBufferPointer<UInt8>(start: ptr, count: requestBody.count))
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
func resolveHandler(_ handler: HTTPRequestHandler) {
|
||||
let chunkHandler = handler(request, self)
|
||||
if shouldStopProcessingBody {
|
||||
return
|
||||
}
|
||||
switch chunkHandler {
|
||||
case .processBody(let handler):
|
||||
_shouldStopProcessingBodyLock.wait()
|
||||
handler(.chunk(data: self.requestBody, finishedProcessing: { self._shouldStopProcessingBodyLock.signal() }), &_shouldStopProcessingBody)
|
||||
var dummy = false
|
||||
handler(.end, &dummy)
|
||||
case .discardBody:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
func writeHeader(status: HTTPResponseStatus, headers: HTTPHeaders, completion: @escaping (Result) -> Void) {
|
||||
self.response = (status: status, headers: headers)
|
||||
completion(.ok)
|
||||
}
|
||||
|
||||
func writeTrailer(_ trailers: HTTPHeaders, completion: @escaping (Result) -> Void) {
|
||||
fatalError("Not implemented")
|
||||
}
|
||||
|
||||
func writeBody(_ data: UnsafeHTTPResponseBody, completion: @escaping (Result) -> Void) {
|
||||
if let data = data as? HTTPResponseBody {
|
||||
self.responseBody = data
|
||||
} else {
|
||||
self.responseBody = data.withUnsafeBytes { Data($0) }
|
||||
}
|
||||
completion(.ok)
|
||||
}
|
||||
|
||||
func done(completion: @escaping (Result) -> Void) {
|
||||
completion(.ok)
|
||||
}
|
||||
func done() /* convenience */ {
|
||||
done { _ in
|
||||
}
|
||||
}
|
||||
|
||||
func abort() {
|
||||
fatalError("abort called, not sure what to do with it")
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import HTTP
|
||||
|
||||
/// Simple `HTTPRequestHandler` that prints "Hello, World" as per K&R
|
||||
class UnchunkedHelloWorldHandler: HTTPRequestHandling {
|
||||
func handle(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
//Assume the router gave us the right request - at least for now
|
||||
let responseString = "Hello, World!"
|
||||
response.writeHeader(status: .ok, headers: [.contentLength: "\(responseString.lengthOfBytes(using: .utf8))"])
|
||||
response.writeBody(responseString)
|
||||
response.done()
|
||||
return .discardBody
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
@testable import HTTP
|
||||
|
||||
class ResponseTests: XCTestCase {
|
||||
|
||||
func testOkay() {
|
||||
let okay = HTTPResponseStatus.ok
|
||||
XCTAssertEqual(200, okay.code)
|
||||
XCTAssertEqual("OK", okay.reasonPhrase)
|
||||
XCTAssertEqual("\(okay)", "200 OK")
|
||||
}
|
||||
|
||||
func testContinue() {
|
||||
XCTAssertEqual("Continue", HTTPResponseStatus.continue.reasonPhrase)
|
||||
}
|
||||
|
||||
func testNotFound() {
|
||||
XCTAssertEqual(HTTPResponseStatus.notFound, HTTPResponseStatus(code: 404))
|
||||
let notFound: HTTPResponseStatus = 404
|
||||
XCTAssertEqual(notFound, HTTPResponseStatus.notFound)
|
||||
}
|
||||
|
||||
static var allTests = [
|
||||
("testOkay", testOkay),
|
||||
("testContinue", testContinue),
|
||||
("testNotFound", testNotFound),
|
||||
]
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import Dispatch
|
||||
|
||||
@testable import HTTP
|
||||
|
||||
class ServerTests: XCTestCase {
|
||||
func testResponseOK() {
|
||||
let request = HTTPRequest(method: .get, target: "/echo", httpVersion: HTTPVersion(major: 1, minor: 1), headers: ["X-foo": "bar"])
|
||||
let resolver = TestResponseResolver(request: request, requestBody: Data())
|
||||
resolver.resolveHandler(EchoHandler().handle)
|
||||
XCTAssertNotNil(resolver.response)
|
||||
XCTAssertNotNil(resolver.responseBody)
|
||||
XCTAssertEqual(HTTPResponseStatus.ok.code, resolver.response?.status.code ?? 0)
|
||||
}
|
||||
|
||||
func testEcho() {
|
||||
let testString = "This is a test"
|
||||
let request = HTTPRequest(method: .post, target: "/echo", httpVersion: HTTPVersion(major: 1, minor: 1), headers: ["X-foo": "bar"])
|
||||
let resolver = TestResponseResolver(request: request, requestBody: testString.data(using: .utf8)!)
|
||||
resolver.resolveHandler(EchoHandler().handle)
|
||||
XCTAssertNotNil(resolver.response)
|
||||
XCTAssertNotNil(resolver.responseBody)
|
||||
XCTAssertEqual(HTTPResponseStatus.ok.code, resolver.response?.status.code ?? 0)
|
||||
XCTAssertEqual(testString, resolver.responseBody?.withUnsafeBytes { String(bytes: $0, encoding: .utf8) } ?? "Nil")
|
||||
}
|
||||
|
||||
func testHello() {
|
||||
let request = HTTPRequest(method: .get, target: "/helloworld", httpVersion: HTTPVersion(major: 1, minor: 1), headers: ["X-foo": "bar"])
|
||||
let resolver = TestResponseResolver(request: request, requestBody: Data())
|
||||
resolver.resolveHandler(HelloWorldHandler().handle)
|
||||
XCTAssertNotNil(resolver.response)
|
||||
XCTAssertNotNil(resolver.responseBody)
|
||||
XCTAssertEqual(HTTPResponseStatus.ok.code, resolver.response?.status.code ?? 0)
|
||||
XCTAssertEqual("Hello, World!", resolver.responseBody?.withUnsafeBytes { String(bytes: $0, encoding: .utf8) } ?? "Nil")
|
||||
}
|
||||
|
||||
func testSimpleHello() {
|
||||
let request = HTTPRequest(method: .get, target: "/helloworld", httpVersion: HTTPVersion(major: 1, minor: 1), headers: ["X-foo": "bar"])
|
||||
let resolver = TestResponseResolver(request: request, requestBody: Data())
|
||||
let simpleHelloWebApp = SimpleResponseCreator { (_, body) -> SimpleResponseCreator.Response in
|
||||
return SimpleResponseCreator.Response(
|
||||
status: .ok,
|
||||
headers: ["X-foo": "bar"],
|
||||
body: "Hello, World!".data(using: .utf8)!
|
||||
)
|
||||
}
|
||||
resolver.resolveHandler(simpleHelloWebApp.handle)
|
||||
XCTAssertNotNil(resolver.response)
|
||||
XCTAssertNotNil(resolver.responseBody)
|
||||
XCTAssertEqual(HTTPResponseStatus.ok.code, resolver.response?.status.code ?? 0)
|
||||
XCTAssertEqual("Hello, World!", resolver.responseBody?.withUnsafeBytes { String(bytes: $0, encoding: .utf8) } ?? "Nil")
|
||||
}
|
||||
|
||||
static var allTests = [
|
||||
("testEcho", testEcho),
|
||||
("testHello", testHello),
|
||||
("testSimpleHello", testSimpleHello),
|
||||
("testResponseOK", testResponseOK),
|
||||
]
|
||||
}
|
||||
@@ -1,494 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import Dispatch
|
||||
|
||||
@testable import HTTP
|
||||
|
||||
class ServerTestsEndToEnd: XCTestCase {
|
||||
func testOkEndToEnd() {
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
|
||||
let options = HTTPServer.Options(onPort: 0)
|
||||
let server = HTTPServer(with: options, requestHandler: OkHandler().handle)
|
||||
do {
|
||||
try server.start()
|
||||
let session = URLSession(configuration: .default)
|
||||
let url = URL(string: "http://localhost:\(server.port)/")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
receivedExpectation.fulfill()
|
||||
}
|
||||
dataTask.resume()
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
func testHelloEndToEnd() {
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
|
||||
let options = HTTPServer.Options(onPort: 0)
|
||||
let server = HTTPServer(with: options, requestHandler: HelloWorldHandler().handle)
|
||||
do {
|
||||
try server.start()
|
||||
let session = URLSession(configuration: .default)
|
||||
let url = URL(string: "http://localhost:\(server.port)/helloworld")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual("Hello, World!", String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
receivedExpectation.fulfill()
|
||||
}
|
||||
dataTask.resume()
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
func testSimpleHelloEndToEnd() {
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
let simpleHelloWebApp = SimpleResponseCreator { (_, body) -> SimpleResponseCreator.Response in
|
||||
return SimpleResponseCreator.Response(
|
||||
status: .ok,
|
||||
headers: ["X-foo": "bar"],
|
||||
body: "Hello, World!".data(using: .utf8)!
|
||||
)
|
||||
}
|
||||
|
||||
let options = HTTPServer.Options(onPort: 0)
|
||||
let server = HTTPServer(with: options, requestHandler: simpleHelloWebApp.handle)
|
||||
do {
|
||||
try server.start()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
|
||||
let session = URLSession(configuration: .default)
|
||||
let url = URL(string: "http://localhost:\(server.port)/helloworld")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
||||
print("\(#function) dataTask returned")
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
let responseString = String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil"
|
||||
XCTAssertEqual("Hello, World!", responseString)
|
||||
print("\(#function) fulfilling expectation")
|
||||
receivedExpectation.fulfill()
|
||||
}
|
||||
dataTask.resume()
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
print("\(#function) stopping server")
|
||||
}
|
||||
|
||||
func testRequestEchoEndToEnd() {
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
let testString="This is a test"
|
||||
|
||||
let options = HTTPServer.Options(onPort: 0)
|
||||
let server = HTTPServer(with: options, requestHandler: EchoHandler().handle)
|
||||
do {
|
||||
try server.start()
|
||||
let session = URLSession(configuration: .default)
|
||||
let url = URL(string: "http://localhost:\(server.port)/echo")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
var request = URLRequest(url: url)
|
||||
request.httpMethod = "POST"
|
||||
request.httpBody = testString.data(using: .utf8)
|
||||
request.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||
|
||||
let dataTask = session.dataTask(with: request) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual(testString, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
receivedExpectation.fulfill()
|
||||
}
|
||||
dataTask.resume()
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
func testRequestKeepAliveEchoEndToEnd() {
|
||||
let receivedExpectation1 = self.expectation(description: "Received web response 1: \(#function)")
|
||||
let receivedExpectation2 = self.expectation(description: "Received web response 2: \(#function)")
|
||||
let receivedExpectation3 = self.expectation(description: "Received web response 3: \(#function)")
|
||||
let testString1="This is a test"
|
||||
let testString2="This is a test, too"
|
||||
let testString3="This is also a test"
|
||||
|
||||
let options = HTTPServer.Options(onPort: 0)
|
||||
let server = HTTPServer(with: options, requestHandler: EchoHandler().handle)
|
||||
do {
|
||||
try server.start()
|
||||
let session = URLSession(configuration: .default)
|
||||
let url = URL(string: "http://localhost:\(server.port)/echo")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
var request1 = URLRequest(url: url)
|
||||
request1.httpMethod = "POST"
|
||||
request1.httpBody = testString1.data(using: .utf8)
|
||||
request1.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||
|
||||
let dataTask1 = session.dataTask(with: request1) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
let headers = response?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||
XCTAssertNotNil(responseBody, "No Response Body")
|
||||
XCTAssertEqual(server.connectionCount, 1)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual(testString1, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
var request2 = URLRequest(url: url)
|
||||
request2.httpMethod = "POST"
|
||||
request2.httpBody = testString2.data(using: .utf8)
|
||||
request2.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||
let dataTask2 = session.dataTask(with: request2) { (responseBody2, rawResponse2, error2) in
|
||||
let response2 = rawResponse2 as? HTTPURLResponse
|
||||
XCTAssertNil(error2, "\(error2!.localizedDescription)")
|
||||
XCTAssertNotNil(response2)
|
||||
let headers = response2?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||
XCTAssertEqual(server.connectionCount, 1)
|
||||
XCTAssertNotNil(responseBody2)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response2?.statusCode ?? 0)
|
||||
XCTAssertEqual(testString2, String(data: responseBody2 ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
var request3 = URLRequest(url: url)
|
||||
request3.httpMethod = "POST"
|
||||
request3.httpBody = testString3.data(using: .utf8)
|
||||
request3.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||
let dataTask3 = session.dataTask(with: request3) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
let headers = response?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||
XCTAssertEqual(server.connectionCount, 1)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual(testString3, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
receivedExpectation3.fulfill()
|
||||
}
|
||||
dataTask3.resume()
|
||||
receivedExpectation2.fulfill()
|
||||
}
|
||||
dataTask2.resume()
|
||||
receivedExpectation1.fulfill()
|
||||
}
|
||||
dataTask1.resume()
|
||||
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
func testMultipleRequestWithoutKeepAliveEchoEndToEnd() {
|
||||
let receivedExpectation1 = self.expectation(description: "Received web response 1: \(#function)")
|
||||
let receivedExpectation2 = self.expectation(description: "Received web response 2: \(#function)")
|
||||
let receivedExpectation3 = self.expectation(description: "Received web response 3: \(#function)")
|
||||
let testString1="This is a test"
|
||||
let testString2="This is a test, too"
|
||||
let testString3="This is also a test"
|
||||
|
||||
let options = HTTPServer.Options(onPort: 0)
|
||||
let server = HTTPServer(with: options, requestHandler: EchoHandler().handle)
|
||||
do {
|
||||
try server.start()
|
||||
let session = URLSession(configuration: .default)
|
||||
let url1 = URL(string: "http://localhost:\(server.port)/echo")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
var request1 = URLRequest(url: url1)
|
||||
request1.httpMethod = "POST"
|
||||
request1.httpBody = testString1.data(using: .utf8)
|
||||
request1.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||
|
||||
let dataTask1 = session.dataTask(with: request1) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
let headers = response?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
let keepAliveHeader = headers["Connection"]
|
||||
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||
XCTAssertNotNil(keepAliveHeader)
|
||||
XCTAssertNotNil(responseBody, "No Keep-Alive Header")
|
||||
XCTAssertEqual(server.connectionCount, 1)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual(testString1, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
let url2 = URL(string: "http://127.0.0.1:\(server.port)/echo")!
|
||||
var request2 = URLRequest(url: url2)
|
||||
request2.httpMethod = "POST"
|
||||
request2.httpBody = testString2.data(using: .utf8)
|
||||
request2.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||
request2.setValue("close", forHTTPHeaderField: "Connection")
|
||||
let dataTask2 = session.dataTask(with: request2) { (responseBody2, rawResponse2, error2) in
|
||||
let response2 = rawResponse2 as? HTTPURLResponse
|
||||
XCTAssertNil(error2, "\(error2!.localizedDescription)")
|
||||
XCTAssertNotNil(response2)
|
||||
let headers = response2?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
let keepAliveHeader = headers["Connection"]
|
||||
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||
XCTAssertNotNil(keepAliveHeader, "No Keep-Alive Header")
|
||||
XCTAssertEqual(server.connectionCount, 2)
|
||||
XCTAssertNotNil(responseBody2)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response2?.statusCode ?? 0)
|
||||
XCTAssertEqual(testString2, String(data: responseBody2 ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
let url3 = URL(string: "http://0.0.0.0:\(server.port)/echo")!
|
||||
var request3 = URLRequest(url: url3)
|
||||
request3.httpMethod = "POST"
|
||||
request3.httpBody = testString3.data(using: .utf8)
|
||||
request3.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||
request3.setValue("close", forHTTPHeaderField: "Connection")
|
||||
let dataTask3 = session.dataTask(with: request3) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
let headers = response?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
let keepAliveHeader = headers["Connection"]
|
||||
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||
XCTAssertNotNil(keepAliveHeader, "No Keep-Alive Header")
|
||||
XCTAssertEqual(server.connectionCount, 3)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual(testString3, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
receivedExpectation3.fulfill()
|
||||
}
|
||||
dataTask3.resume()
|
||||
receivedExpectation2.fulfill()
|
||||
}
|
||||
dataTask2.resume()
|
||||
receivedExpectation1.fulfill()
|
||||
}
|
||||
dataTask1.resume()
|
||||
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
func testRequestLargeEchoEndToEnd() {
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
|
||||
//Use a small chunk size to make sure that we're testing multiple HTTPBodyHandler calls
|
||||
let chunkSize = 1024
|
||||
|
||||
// Get a file we know exists
|
||||
let executableURL = URL(fileURLWithPath: CommandLine.arguments[0])
|
||||
let testExecutableData: Data
|
||||
|
||||
do {
|
||||
testExecutableData = try Data(contentsOf: executableURL)
|
||||
} catch {
|
||||
XCTFail("Could not create Data from contents of \(executableURL)")
|
||||
return
|
||||
}
|
||||
|
||||
var testDataLong = testExecutableData + testExecutableData + testExecutableData + testExecutableData
|
||||
let length = testDataLong.count
|
||||
let keep = 16385
|
||||
let remove = length - keep
|
||||
if remove > 0 {
|
||||
testDataLong.removeLast(remove)
|
||||
}
|
||||
|
||||
let testData = Data(testDataLong)
|
||||
|
||||
let server = PoCSocketSimpleServer()
|
||||
do {
|
||||
try server.start(port: 0, maxReadLength: chunkSize, handler: EchoHandler().handle)
|
||||
let session = URLSession(configuration: .default)
|
||||
let url = URL(string: "http://localhost:\(server.port)/echo")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
var request = URLRequest(url: url)
|
||||
request.httpMethod = "POST"
|
||||
request.httpBody = testData
|
||||
let dataTask = session.dataTask(with: request) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual(testData, responseBody ?? Data())
|
||||
receivedExpectation.fulfill()
|
||||
}
|
||||
dataTask.resume()
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
func testRequestLargePostHelloWorld() {
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
|
||||
//Use a small chunk size to make sure that we stop after one HTTPBodyHandler call
|
||||
let chunkSize = 1024
|
||||
|
||||
// Get a file we know exists
|
||||
let executableURL = URL(fileURLWithPath: CommandLine.arguments[0])
|
||||
let testExecutableData: Data
|
||||
|
||||
do {
|
||||
testExecutableData = try Data(contentsOf: executableURL)
|
||||
} catch {
|
||||
XCTFail("Could not create Data from contents of \(executableURL)")
|
||||
return
|
||||
}
|
||||
|
||||
//Make sure there's data there
|
||||
XCTAssertNotNil(testExecutableData)
|
||||
|
||||
let executableLength = testExecutableData.count
|
||||
|
||||
let server = PoCSocketSimpleServer()
|
||||
do {
|
||||
let testHandler = AbortAndSendHelloHandler()
|
||||
try server.start(port: 0, maxReadLength: chunkSize, handler: testHandler.handle)
|
||||
let session = URLSession(configuration: .default)
|
||||
let url = URL(string: "http://localhost:\(server.port)/echo")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
var request = URLRequest(url: url)
|
||||
request.httpMethod = "POST"
|
||||
let uploadTask = session.uploadTask(with: request, fromFile: executableURL) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual("Hello, World!", String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
XCTAssertEqual(Int(testHandler.chunkCalledCount), 1)
|
||||
XCTAssertLessThan(testHandler.chunkLength, executableLength, "Should have written less than the length of the file")
|
||||
XCTAssertLessThanOrEqual(Int(testHandler.chunkLength), chunkSize)
|
||||
receivedExpectation.fulfill()
|
||||
}
|
||||
uploadTask.resume()
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
func testExplicitCloseConnections() {
|
||||
let expectation = self.expectation(description: "0 Open Connection")
|
||||
let server = PoCSocketSimpleServer()
|
||||
let keepAliveTimeout = 0.1
|
||||
|
||||
do {
|
||||
try server.start(port: 0, keepAliveTimeout: keepAliveTimeout, handler: OkHandler().handle)
|
||||
|
||||
let session = URLSession(configuration: .default)
|
||||
let url1 = URL(string: "http://localhost:\(server.port)")!
|
||||
var request = URLRequest(url: url1)
|
||||
request.httpMethod = "POST"
|
||||
request.setValue("close", forHTTPHeaderField: "Connection")
|
||||
|
||||
let dataTask1 = session.dataTask(with: request) { (_, _, error) in
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
#if os(Linux)
|
||||
XCTAssertEqual(server.connectionCount, 0)
|
||||
expectation.fulfill()
|
||||
|
||||
// Darwin's URLSession replaces the `Connection: close` header with `Connection: keep-alive`, so allow it to expire
|
||||
#else
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + keepAliveTimeout) {
|
||||
XCTAssertEqual(server.connectionCount, 0)
|
||||
expectation.fulfill()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
dataTask1.resume()
|
||||
|
||||
self.waitForExpectations(timeout: 30) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
static var allTests = [
|
||||
("testOkEndToEnd", testOkEndToEnd),
|
||||
("testHelloEndToEnd", testHelloEndToEnd),
|
||||
("testSimpleHelloEndToEnd", testSimpleHelloEndToEnd),
|
||||
("testRequestEchoEndToEnd", testRequestEchoEndToEnd),
|
||||
("testRequestKeepAliveEchoEndToEnd", testRequestKeepAliveEchoEndToEnd),
|
||||
("testRequestLargeEchoEndToEnd", testRequestLargeEchoEndToEnd),
|
||||
("testExplicitCloseConnections", testExplicitCloseConnections),
|
||||
("testRequestLargePostHelloWorld", testRequestLargePostHelloWorld),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,572 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import Dispatch
|
||||
import ServerSecurity
|
||||
|
||||
@testable import HTTP
|
||||
|
||||
class TLSServerTests: XCTestCase {
|
||||
|
||||
func testOkEndToEndTLSwithCA() {
|
||||
let config = createCASignedTLSConfig()
|
||||
testOkEndToEndInternal(config: config, selfsigned: false)
|
||||
}
|
||||
|
||||
func testOkEndToEndTLSwithSelfSigned() {
|
||||
let config = createSelfSignedTLSConfig()
|
||||
testOkEndToEndInternal(config: config, selfsigned: true)
|
||||
}
|
||||
|
||||
func testOkEndToEndInternal(config: TLSConfiguration, selfsigned: Bool) {
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
let urlStr: String
|
||||
let session: URLSession
|
||||
|
||||
let server = HTTPServer(with: HTTPServer.Options(onPort: 0, tlsConf: config), requestHandler: OkHandler().handle)
|
||||
do {
|
||||
try server.start()
|
||||
|
||||
if selfsigned {
|
||||
#if os(OSX)
|
||||
session = URLSession(configuration: URLSessionConfiguration.default, delegate: self, delegateQueue:OperationQueue.main)
|
||||
#else
|
||||
// delegate in URLSession in Linux is not implemented. Using this to compile but it will fail if run on Linux.
|
||||
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
#endif
|
||||
urlStr = "localhost"
|
||||
|
||||
} else {
|
||||
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
urlStr = "ssl.gelareh.xyz"
|
||||
}
|
||||
|
||||
let url = URL(string: "https://\(urlStr):\(server.port)/")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
print("url = \(url.absoluteString) ")
|
||||
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
receivedExpectation.fulfill()
|
||||
}
|
||||
dataTask.resume()
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
func testHelloEndToEndTLSwithCA() {
|
||||
let config = createCASignedTLSConfig()
|
||||
testHelloEndToEndInternal(config: config, selfsigned: false)
|
||||
}
|
||||
|
||||
func testHelloEndToEndTLSwithSelfSigned() {
|
||||
let config = createSelfSignedTLSConfig()
|
||||
testHelloEndToEndInternal(config: config, selfsigned: true)
|
||||
}
|
||||
|
||||
func testHelloEndToEndInternal(config: TLSConfiguration, selfsigned: Bool) {
|
||||
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
let urlStr: String
|
||||
let session: URLSession
|
||||
|
||||
let server = HTTPServer(with: HTTPServer.Options(onPort: 0, tlsConf: config), requestHandler: HelloWorldHandler().handle)
|
||||
do {
|
||||
try server.start()
|
||||
|
||||
if selfsigned {
|
||||
#if os(OSX)
|
||||
session = URLSession(configuration: URLSessionConfiguration.default, delegate: self, delegateQueue:OperationQueue.main)
|
||||
#else
|
||||
// delegate in URLSession in Linux is not implemented. Using this to compile but it will fail if run on Linux.
|
||||
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
#endif
|
||||
urlStr = "localhost"
|
||||
|
||||
} else {
|
||||
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
urlStr = "ssl.gelareh.xyz"
|
||||
}
|
||||
|
||||
let url = URL(string: "https://\(urlStr):\(server.port)/helloworld")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual("Hello, World!", String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
receivedExpectation.fulfill()
|
||||
}
|
||||
dataTask.resume()
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
func testSimpleHelloEndToEndTLSwithCA() {
|
||||
let config = createCASignedTLSConfig()
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
let session: URLSession
|
||||
|
||||
let simpleHelloWebApp = SimpleResponseCreator { (_, body) -> SimpleResponseCreator.Response in
|
||||
return SimpleResponseCreator.Response(
|
||||
status: .ok,
|
||||
headers: ["X-foo": "bar"],
|
||||
body: "Hello, World!".data(using: .utf8)!
|
||||
)
|
||||
}
|
||||
|
||||
let server = HTTPServer(with: HTTPServer.Options(onPort: 0, tlsConf: config), requestHandler: simpleHelloWebApp.handle)
|
||||
do {
|
||||
try server.start()
|
||||
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
|
||||
let url = URL(string: "https://ssl.gelareh.xyz:\(server.port)/helloworld")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
||||
print("\(#function) dataTask returned")
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
let responseString = String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil"
|
||||
XCTAssertEqual("Hello, World!", responseString)
|
||||
print("\(#function) fulfilling expectation")
|
||||
receivedExpectation.fulfill()
|
||||
}
|
||||
dataTask.resume()
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
func testRequestEchoEndToEndTLSwithCA() {
|
||||
let config = createCASignedTLSConfig()
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
let session: URLSession
|
||||
let testString = "This is a test"
|
||||
|
||||
let server = HTTPServer(with: HTTPServer.Options(onPort: 0, tlsConf: config), requestHandler: EchoHandler().handle)
|
||||
do {
|
||||
try server.start()
|
||||
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
|
||||
let url = URL(string: "https://ssl.gelareh.xyz:\(server.port)/echo")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
var request = URLRequest(url: url)
|
||||
request.httpMethod = "POST"
|
||||
request.httpBody = testString.data(using: .utf8)
|
||||
request.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||
|
||||
let dataTask = session.dataTask(with: request) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual(testString, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
receivedExpectation.fulfill()
|
||||
}
|
||||
dataTask.resume()
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
func testRequestKeepAliveEchoEndToEndTLSwithCA() {
|
||||
let config = createCASignedTLSConfig()
|
||||
let receivedExpectation1 = self.expectation(description: "Received web response 1: \(#function)")
|
||||
let receivedExpectation2 = self.expectation(description: "Received web response 2: \(#function)")
|
||||
let receivedExpectation3 = self.expectation(description: "Received web response 3: \(#function)")
|
||||
let testString1="This is a test"
|
||||
let testString2="This is a test, too"
|
||||
let testString3="This is also a test"
|
||||
let session: URLSession
|
||||
|
||||
let server = HTTPServer(with: HTTPServer.Options(onPort: 0, tlsConf: config), requestHandler: EchoHandler().handle)
|
||||
do {
|
||||
try server.start()
|
||||
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
|
||||
let url = URL(string: "https://ssl.gelareh.xyz:\(server.port)/echo")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
var request1 = URLRequest(url: url)
|
||||
request1.httpMethod = "POST"
|
||||
request1.httpBody = testString1.data(using: .utf8)
|
||||
request1.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||
|
||||
let dataTask1 = session.dataTask(with: request1) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
let headers = response?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||
XCTAssertNotNil(responseBody, "No Response Body")
|
||||
XCTAssertEqual(server.connectionCount, 1)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual(testString1, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
var request2 = URLRequest(url: url)
|
||||
request2.httpMethod = "POST"
|
||||
request2.httpBody = testString2.data(using: .utf8)
|
||||
request2.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||
let dataTask2 = session.dataTask(with: request2) { (responseBody2, rawResponse2, error2) in
|
||||
let response2 = rawResponse2 as? HTTPURLResponse
|
||||
XCTAssertNil(error2, "\(error2!.localizedDescription)")
|
||||
XCTAssertNotNil(response2)
|
||||
let headers = response2?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||
XCTAssertEqual(server.connectionCount, 1)
|
||||
XCTAssertNotNil(responseBody2)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response2?.statusCode ?? 0)
|
||||
XCTAssertEqual(testString2, String(data: responseBody2 ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
var request3 = URLRequest(url: url)
|
||||
request3.httpMethod = "POST"
|
||||
request3.httpBody = testString3.data(using: .utf8)
|
||||
request3.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||
let dataTask3 = session.dataTask(with: request3) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
let headers = response?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||
XCTAssertEqual(server.connectionCount, 1)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual(testString3, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
receivedExpectation3.fulfill()
|
||||
}
|
||||
dataTask3.resume()
|
||||
receivedExpectation2.fulfill()
|
||||
}
|
||||
dataTask2.resume()
|
||||
receivedExpectation1.fulfill()
|
||||
}
|
||||
dataTask1.resume()
|
||||
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
func testMultipleRequestWithoutKeepAliveEchoEndToEndTLSwithCA() {
|
||||
let config = createCASignedTLSConfig()
|
||||
let receivedExpectation1 = self.expectation(description: "Received web response 1: \(#function)")
|
||||
let receivedExpectation2 = self.expectation(description: "Received web response 2: \(#function)")
|
||||
let receivedExpectation3 = self.expectation(description: "Received web response 3: \(#function)")
|
||||
let testString1="This is a test"
|
||||
let testString2="This is a test, too"
|
||||
let testString3="This is also a test"
|
||||
let session: URLSession
|
||||
|
||||
let server = HTTPServer(with: HTTPServer.Options(onPort: 0, tlsConf: config), requestHandler: EchoHandler().handle)
|
||||
do {
|
||||
try server.start()
|
||||
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
|
||||
let url1 = URL(string: "https://ssl.gelareh.xyz:\(server.port)/echo")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
var request1 = URLRequest(url: url1)
|
||||
request1.httpMethod = "POST"
|
||||
request1.httpBody = testString1.data(using: .utf8)
|
||||
request1.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||
request1.setValue("Keep-Alive", forHTTPHeaderField: "Connection")
|
||||
|
||||
let dataTask1 = session.dataTask(with: request1) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
let headers = response?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
let keepAliveHeader = headers["Connection"]
|
||||
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||
XCTAssertNotNil(keepAliveHeader)
|
||||
XCTAssertNotNil(responseBody, "No Keep-Alive Header")
|
||||
XCTAssertEqual(server.connectionCount, 1)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual(testString1, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
let url2 = URL(string: "https://ssl1.gelareh.xyz:\(server.port)/echo")!
|
||||
var request2 = URLRequest(url: url2)
|
||||
request2.httpMethod = "POST"
|
||||
request2.httpBody = testString2.data(using: .utf8)
|
||||
request2.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||
request2.setValue("Keep-Alive", forHTTPHeaderField: "Connection")
|
||||
let dataTask2 = session.dataTask(with: request2) { (responseBody2, rawResponse2, error2) in
|
||||
let response2 = rawResponse2 as? HTTPURLResponse
|
||||
XCTAssertNil(error2, "\(error2!.localizedDescription)")
|
||||
XCTAssertNotNil(response2)
|
||||
let headers = response2?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
let keepAliveHeader = headers["Connection"]
|
||||
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||
XCTAssertNotNil(keepAliveHeader, "No Keep-Alive Header")
|
||||
XCTAssertEqual(server.connectionCount, 2)
|
||||
XCTAssertNotNil(responseBody2)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response2?.statusCode ?? 0)
|
||||
XCTAssertEqual(testString2, String(data: responseBody2 ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
let url3 = URL(string: "https://ssl2.gelareh.xyz:\(server.port)/echo")!
|
||||
var request3 = URLRequest(url: url3)
|
||||
request3.httpMethod = "POST"
|
||||
request3.httpBody = testString3.data(using: .utf8)
|
||||
request3.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||
request3.setValue("Keep-Alive", forHTTPHeaderField: "Connection")
|
||||
let dataTask3 = session.dataTask(with: request3) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
let headers = response?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
let keepAliveHeader = headers["Connection"]
|
||||
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||
XCTAssertNotNil(keepAliveHeader, "No Keep-Alive Header")
|
||||
XCTAssertEqual(server.connectionCount, 3)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual(testString3, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
receivedExpectation3.fulfill()
|
||||
}
|
||||
dataTask3.resume()
|
||||
receivedExpectation2.fulfill()
|
||||
}
|
||||
dataTask2.resume()
|
||||
receivedExpectation1.fulfill()
|
||||
}
|
||||
dataTask1.resume()
|
||||
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
func testRequestLargeEchoEndToEndTLSwithCA() {
|
||||
let config = createCASignedTLSConfig()
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
let session: URLSession
|
||||
|
||||
//Use a small chunk size to make sure that we're testing multiple HTTPBodyHandler calls
|
||||
let chunkSize = 1024
|
||||
|
||||
// Get a file we know exists
|
||||
let executableURL = URL(fileURLWithPath: CommandLine.arguments[0])
|
||||
let testExecutableData: Data
|
||||
|
||||
do {
|
||||
testExecutableData = try Data(contentsOf: executableURL)
|
||||
} catch {
|
||||
XCTFail("Could not create Data from contents of \(executableURL)")
|
||||
return
|
||||
}
|
||||
|
||||
var testDataLong = testExecutableData + testExecutableData + testExecutableData + testExecutableData
|
||||
let length = testDataLong.count
|
||||
let keep = 16385
|
||||
let remove = length - keep
|
||||
if remove > 0 {
|
||||
testDataLong.removeLast(remove)
|
||||
}
|
||||
|
||||
let testData = Data(testDataLong)
|
||||
|
||||
let server = PoCSocketSimpleServer()
|
||||
do {
|
||||
try server.start(port: 0, maxReadLength: chunkSize, tls: config, handler: EchoHandler().handle)
|
||||
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
|
||||
let url = URL(string: "https://ssl.gelareh.xyz:\(server.port)/echo")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
var request = URLRequest(url: url)
|
||||
request.httpMethod = "POST"
|
||||
request.httpBody = testData
|
||||
let dataTask = session.dataTask(with: request) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual(testData, responseBody ?? Data())
|
||||
receivedExpectation.fulfill()
|
||||
}
|
||||
dataTask.resume()
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
func testRequestLargePostHelloWorldTLSwithCA() {
|
||||
let config = createCASignedTLSConfig()
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
let session: URLSession
|
||||
|
||||
// Use a small chunk size to make sure that we stop after one HTTPBodyHandler call
|
||||
let chunkSize = 1024
|
||||
|
||||
// Get a file we know exists
|
||||
let executableURL = URL(fileURLWithPath: CommandLine.arguments[0])
|
||||
let testExecutableData: Data
|
||||
|
||||
do {
|
||||
testExecutableData = try Data(contentsOf: executableURL)
|
||||
} catch {
|
||||
XCTFail("Could not create Data from contents of \(executableURL)")
|
||||
return
|
||||
}
|
||||
|
||||
//Make sure there's data there
|
||||
XCTAssertNotNil(testExecutableData)
|
||||
|
||||
let executableLength = testExecutableData.count
|
||||
|
||||
let server = PoCSocketSimpleServer()
|
||||
do {
|
||||
let testHandler = AbortAndSendHelloHandler()
|
||||
try server.start(port: 0, maxReadLength: chunkSize, tls: config, handler: testHandler.handle)
|
||||
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
|
||||
let url = URL(string: "https://ssl.gelareh.xyz:\(server.port)/echo")!
|
||||
var request = URLRequest(url: url)
|
||||
request.httpMethod = "POST"
|
||||
let uploadTask = session.uploadTask(with: request, fromFile: executableURL) { (responseBody, rawResponse, error) in
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
XCTAssertEqual("Hello, World!", String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||
XCTAssertEqual(Int(testHandler.chunkCalledCount), 1)
|
||||
XCTAssertLessThan(testHandler.chunkLength, executableLength, "Should have written less than the length of the file")
|
||||
if (chunkSize < TLSConstants.maxTLSRecordLength) {
|
||||
XCTAssertLessThanOrEqual(Int(testHandler.chunkLength), TLSConstants.maxTLSRecordLength)
|
||||
} else {
|
||||
XCTAssertLessThanOrEqual(Int(testHandler.chunkLength), chunkSize)
|
||||
}
|
||||
receivedExpectation.fulfill()
|
||||
}
|
||||
uploadTask.resume()
|
||||
self.waitForExpectations(timeout: 10) { (error) in
|
||||
if let error = error {
|
||||
XCTFail("\(error)")
|
||||
}
|
||||
}
|
||||
server.stop()
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
}
|
||||
|
||||
private func createSelfSignedTLSConfig() -> TLSConfiguration {
|
||||
#if os(Linux)
|
||||
let myCAPath = URL(fileURLWithPath: #file).appendingPathComponent("../../Certs/Self-Signed/chain.pem").standardized
|
||||
let myCertPath = URL(fileURLWithPath: #file).appendingPathComponent("../../Certs/Self-Signed/cert.pem").standardized
|
||||
let myKeyPath = URL(fileURLWithPath: #file).appendingPathComponent("../../Certs/Self-Signed/key.pem").standardized
|
||||
let config = TLSConfiguration(withCACertificateFilePath: myCAPath.path, usingCertificateFile: myCertPath.path, withKeyFile: myKeyPath.path, usingSelfSignedCerts: true)
|
||||
#else
|
||||
let myP12 = URL(fileURLWithPath: #file).appendingPathComponent("../../../Certs/Self-Signed/cert.pfx").standardized
|
||||
let myPassword = "sw!ft!sC00l"
|
||||
let config = TLSConfiguration(withChainFilePath: myP12.path, withPassword: myPassword, usingSelfSignedCerts: true)
|
||||
#endif
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
private func createCASignedTLSConfig() -> TLSConfiguration {
|
||||
#if os(Linux)
|
||||
|
||||
let myCAPath = URL(fileURLWithPath: #file).appendingPathComponent("../../../Certs/letsEncryptCA/chain.pem").standardized
|
||||
let myCertPath = URL(fileURLWithPath: #file).appendingPathComponent("../../../Certs/letsEncryptCA/cert.pem").standardized
|
||||
let myKeyPath = URL(fileURLWithPath: #file).appendingPathComponent("../../../Certs/letsEncryptCA/key.pem").standardized
|
||||
let config = TLSConfiguration(withCACertificateFilePath: myCAPath.path, usingCertificateFile: myCertPath.path, withKeyFile: myKeyPath.path, usingSelfSignedCerts: false)
|
||||
// print("myCAPath is at: \(myCAPath.absoluteString) ")
|
||||
// print("myCertPath is at: \(myCertPath.absoluteString) ")
|
||||
// print("myKeyPath is at: \(myKeyPath.absoluteString) ")
|
||||
|
||||
#else
|
||||
let myP12 = URL(fileURLWithPath: #file).appendingPathComponent("../../../Certs/letsEncryptCA/cert.pfx").standardized
|
||||
let myPassword = "password"
|
||||
let config = TLSConfiguration(withChainFilePath: myP12.path, withPassword: myPassword, usingSelfSignedCerts: false)
|
||||
// print("myCertPath is at: \(myP12.absoluteString) ")
|
||||
|
||||
#endif
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
static var allTests = [
|
||||
("testOkEndToEndTLSwithCA", testOkEndToEndTLSwithCA),
|
||||
("testHelloEndToEndTLSwithCA", testHelloEndToEndTLSwithCA),
|
||||
("testSimpleHelloEndToEndTLSwithCA", testSimpleHelloEndToEndTLSwithCA),
|
||||
("testRequestEchoEndToEndTLSwithCA", testRequestEchoEndToEndTLSwithCA),
|
||||
("testRequestKeepAliveEchoEndToEndTLSwithCA", testRequestKeepAliveEchoEndToEndTLSwithCA),
|
||||
("testRequestLargeEchoEndToEndTLSwithCA", testRequestLargeEchoEndToEndTLSwithCA),
|
||||
("testMultipleRequestWithoutKeepAliveEchoEndToEndTLSwithCA", testMultipleRequestWithoutKeepAliveEchoEndToEndTLSwithCA),
|
||||
("testRequestLargePostHelloWorldTLSwithCA", testRequestLargePostHelloWorldTLSwithCA),
|
||||
]
|
||||
}
|
||||
|
||||
#if os(OSX)
|
||||
extension TLSServerTests: URLSessionDelegate {
|
||||
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
||||
completionHandler(URLSession.AuthChallengeDisposition.useCredential, URLCredential(trust: challenge.protectionSpace.serverTrust!) )
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
@testable import HTTP
|
||||
|
||||
class VersionTests: XCTestCase {
|
||||
let version10 = HTTPVersion(major: 1, minor: 0)
|
||||
let version11 = HTTPVersion(major: 1, minor: 1)
|
||||
let version20 = HTTPVersion(major: 2, minor: 0)
|
||||
|
||||
func testEquals() {
|
||||
XCTAssertEqual(version10, version10)
|
||||
XCTAssertEqual(version11, version11)
|
||||
XCTAssertEqual(version20, version20)
|
||||
|
||||
XCTAssertNotEqual(version10, version11)
|
||||
XCTAssertNotEqual(version11, version10)
|
||||
XCTAssertNotEqual(version20, version10)
|
||||
XCTAssertNotEqual(version20, version11)
|
||||
}
|
||||
|
||||
func testGreater() {
|
||||
XCTAssertGreaterThan(version11, version10)
|
||||
XCTAssertGreaterThan(version20, version10)
|
||||
XCTAssertGreaterThan(version20, version11)
|
||||
|
||||
XCTAssertGreaterThanOrEqual(version10, version10)
|
||||
XCTAssertGreaterThanOrEqual(version11, version11)
|
||||
XCTAssertGreaterThanOrEqual(version20, version20)
|
||||
|
||||
XCTAssertFalse(version10 > version11)
|
||||
XCTAssertFalse(version10 > version20)
|
||||
XCTAssertFalse(version11 > version20)
|
||||
|
||||
XCTAssertFalse(version10 >= version11)
|
||||
XCTAssertFalse(version10 >= version20)
|
||||
XCTAssertFalse(version11 >= version20)
|
||||
}
|
||||
|
||||
func testLess() {
|
||||
XCTAssertLessThan(version10, version11)
|
||||
XCTAssertLessThan(version10, version20)
|
||||
XCTAssertLessThan(version11, version20)
|
||||
|
||||
XCTAssertLessThanOrEqual(version10, version10)
|
||||
XCTAssertLessThanOrEqual(version11, version11)
|
||||
XCTAssertLessThanOrEqual(version20, version20)
|
||||
|
||||
XCTAssertFalse(version11 < version10)
|
||||
XCTAssertFalse(version20 < version10)
|
||||
XCTAssertFalse(version20 < version11)
|
||||
|
||||
XCTAssertFalse(version11 <= version10)
|
||||
XCTAssertFalse(version20 <= version10)
|
||||
XCTAssertFalse(version20 <= version11)
|
||||
}
|
||||
|
||||
func testHashValue() {
|
||||
XCTAssertEqual(version10.hashValue, HTTPVersion(major: 1, minor: 0).hashValue)
|
||||
XCTAssertEqual(version11.hashValue, HTTPVersion(major: 1, minor: 1).hashValue)
|
||||
XCTAssertEqual(version20.hashValue, HTTPVersion(major: 2, minor: 0).hashValue)
|
||||
|
||||
XCTAssertNotEqual(version10.hashValue, HTTPVersion(major: 1, minor: 1).hashValue)
|
||||
XCTAssertNotEqual(version11.hashValue, HTTPVersion(major: 1, minor: 0).hashValue)
|
||||
XCTAssertNotEqual(version20.hashValue, HTTPVersion(major: 1, minor: 0).hashValue)
|
||||
XCTAssertNotEqual(version20.hashValue, HTTPVersion(major: 1, minor: 1).hashValue)
|
||||
}
|
||||
|
||||
func testDescription() {
|
||||
XCTAssertEqual(version10.description, "HTTP/1.0")
|
||||
XCTAssertEqual(version11.description, "HTTP/1.1")
|
||||
XCTAssertEqual(version20.description, "HTTP/2.0")
|
||||
}
|
||||
|
||||
static var allTests = [
|
||||
("testEquals", testEquals),
|
||||
("testGreater", testGreater),
|
||||
("testLess", testLess),
|
||||
("testHashValue", testHashValue),
|
||||
("testDescription", testDescription)
|
||||
]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
// This source file is part of the Swift.org Server APIs open source project
|
||||
//
|
||||
// Copyright (c) 2017 Swift Server API project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import HTTPTests
|
||||
|
||||
XCTMain([
|
||||
// HTTPTests
|
||||
testCase(VersionTests.allTests),
|
||||
testCase(HeadersTests.allTests),
|
||||
testCase(ResponseTests.allTests),
|
||||
testCase(ServerTests.allTests),
|
||||
testCase(ServerTestsEndToEnd.allTests),
|
||||
testCase(TLSServerTests.allTests),
|
||||
])
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="136" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="136" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h93v20H0z"/><path fill="#4c1" d="M93 0h43v20H93z"/><path fill="url(#b)" d="M0 0h136v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="46.5" y="15" fill="#010101" fill-opacity=".3">documentation</text><text x="46.5" y="14">documentation</text><text x="113.5" y="15" fill="#010101" fill-opacity=".3">100%</text><text x="113.5" y="14">100%</text></g></svg>
|
||||
|
After Width: | Height: | Size: 807 B |
@@ -0,0 +1,200 @@
|
||||
/* Credit to https://gist.github.com/wataru420/2048287 */
|
||||
.highlight {
|
||||
/* Comment */
|
||||
/* Error */
|
||||
/* Keyword */
|
||||
/* Operator */
|
||||
/* Comment.Multiline */
|
||||
/* Comment.Preproc */
|
||||
/* Comment.Single */
|
||||
/* Comment.Special */
|
||||
/* Generic.Deleted */
|
||||
/* Generic.Deleted.Specific */
|
||||
/* Generic.Emph */
|
||||
/* Generic.Error */
|
||||
/* Generic.Heading */
|
||||
/* Generic.Inserted */
|
||||
/* Generic.Inserted.Specific */
|
||||
/* Generic.Output */
|
||||
/* Generic.Prompt */
|
||||
/* Generic.Strong */
|
||||
/* Generic.Subheading */
|
||||
/* Generic.Traceback */
|
||||
/* Keyword.Constant */
|
||||
/* Keyword.Declaration */
|
||||
/* Keyword.Pseudo */
|
||||
/* Keyword.Reserved */
|
||||
/* Keyword.Type */
|
||||
/* Literal.Number */
|
||||
/* Literal.String */
|
||||
/* Name.Attribute */
|
||||
/* Name.Builtin */
|
||||
/* Name.Class */
|
||||
/* Name.Constant */
|
||||
/* Name.Entity */
|
||||
/* Name.Exception */
|
||||
/* Name.Function */
|
||||
/* Name.Namespace */
|
||||
/* Name.Tag */
|
||||
/* Name.Variable */
|
||||
/* Operator.Word */
|
||||
/* Text.Whitespace */
|
||||
/* Literal.Number.Float */
|
||||
/* Literal.Number.Hex */
|
||||
/* Literal.Number.Integer */
|
||||
/* Literal.Number.Oct */
|
||||
/* Literal.String.Backtick */
|
||||
/* Literal.String.Char */
|
||||
/* Literal.String.Doc */
|
||||
/* Literal.String.Double */
|
||||
/* Literal.String.Escape */
|
||||
/* Literal.String.Heredoc */
|
||||
/* Literal.String.Interpol */
|
||||
/* Literal.String.Other */
|
||||
/* Literal.String.Regex */
|
||||
/* Literal.String.Single */
|
||||
/* Literal.String.Symbol */
|
||||
/* Name.Builtin.Pseudo */
|
||||
/* Name.Variable.Class */
|
||||
/* Name.Variable.Global */
|
||||
/* Name.Variable.Instance */
|
||||
/* Literal.Number.Integer.Long */ }
|
||||
.highlight .c {
|
||||
color: #999988;
|
||||
font-style: italic; }
|
||||
.highlight .err {
|
||||
color: #a61717;
|
||||
background-color: #e3d2d2; }
|
||||
.highlight .k {
|
||||
color: #000000;
|
||||
font-weight: bold; }
|
||||
.highlight .o {
|
||||
color: #000000;
|
||||
font-weight: bold; }
|
||||
.highlight .cm {
|
||||
color: #999988;
|
||||
font-style: italic; }
|
||||
.highlight .cp {
|
||||
color: #999999;
|
||||
font-weight: bold; }
|
||||
.highlight .c1 {
|
||||
color: #999988;
|
||||
font-style: italic; }
|
||||
.highlight .cs {
|
||||
color: #999999;
|
||||
font-weight: bold;
|
||||
font-style: italic; }
|
||||
.highlight .gd {
|
||||
color: #000000;
|
||||
background-color: #ffdddd; }
|
||||
.highlight .gd .x {
|
||||
color: #000000;
|
||||
background-color: #ffaaaa; }
|
||||
.highlight .ge {
|
||||
color: #000000;
|
||||
font-style: italic; }
|
||||
.highlight .gr {
|
||||
color: #aa0000; }
|
||||
.highlight .gh {
|
||||
color: #999999; }
|
||||
.highlight .gi {
|
||||
color: #000000;
|
||||
background-color: #ddffdd; }
|
||||
.highlight .gi .x {
|
||||
color: #000000;
|
||||
background-color: #aaffaa; }
|
||||
.highlight .go {
|
||||
color: #888888; }
|
||||
.highlight .gp {
|
||||
color: #555555; }
|
||||
.highlight .gs {
|
||||
font-weight: bold; }
|
||||
.highlight .gu {
|
||||
color: #aaaaaa; }
|
||||
.highlight .gt {
|
||||
color: #aa0000; }
|
||||
.highlight .kc {
|
||||
color: #000000;
|
||||
font-weight: bold; }
|
||||
.highlight .kd {
|
||||
color: #000000;
|
||||
font-weight: bold; }
|
||||
.highlight .kp {
|
||||
color: #000000;
|
||||
font-weight: bold; }
|
||||
.highlight .kr {
|
||||
color: #000000;
|
||||
font-weight: bold; }
|
||||
.highlight .kt {
|
||||
color: #445588; }
|
||||
.highlight .m {
|
||||
color: #009999; }
|
||||
.highlight .s {
|
||||
color: #d14; }
|
||||
.highlight .na {
|
||||
color: #008080; }
|
||||
.highlight .nb {
|
||||
color: #0086B3; }
|
||||
.highlight .nc {
|
||||
color: #445588;
|
||||
font-weight: bold; }
|
||||
.highlight .no {
|
||||
color: #008080; }
|
||||
.highlight .ni {
|
||||
color: #800080; }
|
||||
.highlight .ne {
|
||||
color: #990000;
|
||||
font-weight: bold; }
|
||||
.highlight .nf {
|
||||
color: #990000; }
|
||||
.highlight .nn {
|
||||
color: #555555; }
|
||||
.highlight .nt {
|
||||
color: #000080; }
|
||||
.highlight .nv {
|
||||
color: #008080; }
|
||||
.highlight .ow {
|
||||
color: #000000;
|
||||
font-weight: bold; }
|
||||
.highlight .w {
|
||||
color: #bbbbbb; }
|
||||
.highlight .mf {
|
||||
color: #009999; }
|
||||
.highlight .mh {
|
||||
color: #009999; }
|
||||
.highlight .mi {
|
||||
color: #009999; }
|
||||
.highlight .mo {
|
||||
color: #009999; }
|
||||
.highlight .sb {
|
||||
color: #d14; }
|
||||
.highlight .sc {
|
||||
color: #d14; }
|
||||
.highlight .sd {
|
||||
color: #d14; }
|
||||
.highlight .s2 {
|
||||
color: #d14; }
|
||||
.highlight .se {
|
||||
color: #d14; }
|
||||
.highlight .sh {
|
||||
color: #d14; }
|
||||
.highlight .si {
|
||||
color: #d14; }
|
||||
.highlight .sx {
|
||||
color: #d14; }
|
||||
.highlight .sr {
|
||||
color: #009926; }
|
||||
.highlight .s1 {
|
||||
color: #d14; }
|
||||
.highlight .ss {
|
||||
color: #990073; }
|
||||
.highlight .bp {
|
||||
color: #999999; }
|
||||
.highlight .vc {
|
||||
color: #008080; }
|
||||
.highlight .vg {
|
||||
color: #008080; }
|
||||
.highlight .vi {
|
||||
color: #008080; }
|
||||
.highlight .il {
|
||||
color: #009999; }
|
||||
+368
@@ -0,0 +1,368 @@
|
||||
*, *:before, *:after {
|
||||
box-sizing: inherit; }
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: #fff;
|
||||
color: #333;
|
||||
font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
letter-spacing: .2px;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
box-sizing: border-box; }
|
||||
|
||||
h1 {
|
||||
font-size: 2rem;
|
||||
font-weight: 700;
|
||||
margin: 1.275em 0 0.6em; }
|
||||
|
||||
h2 {
|
||||
font-size: 1.75rem;
|
||||
font-weight: 700;
|
||||
margin: 1.275em 0 0.3em; }
|
||||
|
||||
h3 {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
margin: 1em 0 0.3em; }
|
||||
|
||||
h4 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
margin: 1.275em 0 0.85em; }
|
||||
|
||||
h5 {
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
margin: 1.275em 0 0.85em; }
|
||||
|
||||
h6 {
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
margin: 1.275em 0 0.85em;
|
||||
color: #777; }
|
||||
|
||||
p {
|
||||
margin: 0 0 1em; }
|
||||
|
||||
ul, ol {
|
||||
padding: 0 0 0 2em;
|
||||
margin: 0 0 0.85em; }
|
||||
|
||||
blockquote {
|
||||
margin: 0 0 0.85em;
|
||||
padding: 0 15px;
|
||||
color: #858585;
|
||||
border-left: 4px solid #e5e5e5; }
|
||||
|
||||
img {
|
||||
max-width: 100%; }
|
||||
|
||||
a {
|
||||
color: #4183c4;
|
||||
text-decoration: none; }
|
||||
a:hover, a:focus {
|
||||
outline: 0;
|
||||
text-decoration: underline; }
|
||||
|
||||
table {
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
overflow: auto;
|
||||
margin: 0 0 0.85em; }
|
||||
|
||||
tr:nth-child(2n) {
|
||||
background-color: #fbfbfb; }
|
||||
|
||||
th, td {
|
||||
padding: 6px 13px;
|
||||
border: 1px solid #ddd; }
|
||||
|
||||
pre {
|
||||
margin: 0 0 1.275em;
|
||||
padding: .85em 1em;
|
||||
overflow: auto;
|
||||
background: #f7f7f7;
|
||||
font-size: .85em;
|
||||
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; }
|
||||
|
||||
code {
|
||||
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; }
|
||||
|
||||
p > code, li > code {
|
||||
background: #f7f7f7;
|
||||
padding: .2em; }
|
||||
p > code:before, p > code:after, li > code:before, li > code:after {
|
||||
letter-spacing: -.2em;
|
||||
content: "\00a0"; }
|
||||
|
||||
pre code {
|
||||
padding: 0;
|
||||
white-space: pre; }
|
||||
|
||||
.content-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column; }
|
||||
@media (min-width: 768px) {
|
||||
.content-wrapper {
|
||||
flex-direction: row; } }
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
padding: 8px;
|
||||
font-size: 0.875em;
|
||||
background: #444;
|
||||
color: #999; }
|
||||
|
||||
.header-col {
|
||||
margin: 0;
|
||||
padding: 0 8px; }
|
||||
|
||||
.header-col--primary {
|
||||
flex: 1; }
|
||||
|
||||
.header-link {
|
||||
color: #fff; }
|
||||
|
||||
.header-icon {
|
||||
padding-right: 6px;
|
||||
vertical-align: -4px;
|
||||
height: 16px; }
|
||||
|
||||
.breadcrumbs {
|
||||
font-size: 0.875em;
|
||||
padding: 8px 16px;
|
||||
margin: 0;
|
||||
background: #fbfbfb;
|
||||
border-bottom: 1px solid #ddd; }
|
||||
|
||||
.carat {
|
||||
height: 10px;
|
||||
margin: 0 5px; }
|
||||
|
||||
.navigation {
|
||||
order: 2; }
|
||||
@media (min-width: 768px) {
|
||||
.navigation {
|
||||
order: 1;
|
||||
width: 25%;
|
||||
max-width: 300px;
|
||||
padding-bottom: 64px;
|
||||
overflow: hidden;
|
||||
word-wrap: normal;
|
||||
background: #fbfbfb;
|
||||
border-right: 1px solid #ddd; } }
|
||||
|
||||
.nav-groups {
|
||||
list-style-type: none;
|
||||
padding-left: 0; }
|
||||
|
||||
.nav-group-name {
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 8px 0 8px 16px; }
|
||||
|
||||
.nav-group-name-link {
|
||||
color: #333; }
|
||||
|
||||
.nav-group-tasks {
|
||||
margin: 8px 0;
|
||||
padding: 0 0 0 8px; }
|
||||
|
||||
.nav-group-task {
|
||||
font-size: 1em;
|
||||
list-style-type: none;
|
||||
white-space: nowrap; }
|
||||
|
||||
.nav-group-task-link {
|
||||
color: #808080; }
|
||||
|
||||
.main-content {
|
||||
order: 1; }
|
||||
@media (min-width: 768px) {
|
||||
.main-content {
|
||||
order: 2;
|
||||
flex: 1;
|
||||
padding-bottom: 60px; } }
|
||||
|
||||
.section {
|
||||
padding: 0 32px;
|
||||
border-bottom: 1px solid #ddd; }
|
||||
|
||||
.section-content {
|
||||
max-width: 834px;
|
||||
margin: 0 auto;
|
||||
padding: 16px 0; }
|
||||
|
||||
.section-name {
|
||||
color: #666;
|
||||
display: block; }
|
||||
|
||||
.declaration .highlight {
|
||||
overflow-x: initial;
|
||||
padding: 8px 0;
|
||||
margin: 0;
|
||||
background-color: transparent;
|
||||
border: none; }
|
||||
|
||||
.task-group-section {
|
||||
border-top: 1px solid #ddd; }
|
||||
|
||||
.task-group {
|
||||
padding-top: 0px; }
|
||||
|
||||
.task-name-container a[name]:before {
|
||||
content: "";
|
||||
display: block; }
|
||||
|
||||
.item-container {
|
||||
padding: 0; }
|
||||
|
||||
.item {
|
||||
padding-top: 8px;
|
||||
width: 100%;
|
||||
list-style-type: none; }
|
||||
.item a[name]:before {
|
||||
content: "";
|
||||
display: block; }
|
||||
.item .token {
|
||||
padding-left: 3px;
|
||||
margin-left: 0px;
|
||||
font-size: 1rem; }
|
||||
.item .declaration-note {
|
||||
font-size: .85em;
|
||||
color: #808080;
|
||||
font-style: italic; }
|
||||
|
||||
.pointer-container {
|
||||
border-bottom: 1px solid #ddd;
|
||||
left: -23px;
|
||||
padding-bottom: 13px;
|
||||
position: relative;
|
||||
width: 110%; }
|
||||
|
||||
.pointer {
|
||||
left: 21px;
|
||||
top: 7px;
|
||||
display: block;
|
||||
position: absolute;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-left: 1px solid #ddd;
|
||||
border-top: 1px solid #ddd;
|
||||
background: #fff;
|
||||
transform: rotate(45deg); }
|
||||
|
||||
.height-container {
|
||||
display: none;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
overflow: hidden; }
|
||||
.height-container .section {
|
||||
background: #fff;
|
||||
border: 1px solid #ddd;
|
||||
border-top-width: 0;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 5px;
|
||||
padding: 8px 16px; }
|
||||
|
||||
.aside, .language {
|
||||
padding: 6px 12px;
|
||||
margin: 12px 0;
|
||||
border-left: 5px solid #dddddd;
|
||||
overflow-y: hidden; }
|
||||
.aside .aside-title, .language .aside-title {
|
||||
font-size: 9px;
|
||||
letter-spacing: 2px;
|
||||
text-transform: uppercase;
|
||||
padding-bottom: 0;
|
||||
margin: 0;
|
||||
color: #aaa;
|
||||
-webkit-user-select: none; }
|
||||
.aside p:last-child, .language p:last-child {
|
||||
margin-bottom: 0; }
|
||||
|
||||
.language {
|
||||
border-left: 5px solid #cde9f4; }
|
||||
.language .aside-title {
|
||||
color: #4183c4; }
|
||||
|
||||
.aside-warning {
|
||||
border-left: 5px solid #ff6666; }
|
||||
.aside-warning .aside-title {
|
||||
color: #ff0000; }
|
||||
|
||||
.graybox {
|
||||
border-collapse: collapse;
|
||||
width: 100%; }
|
||||
.graybox p {
|
||||
margin: 0;
|
||||
word-break: break-word;
|
||||
min-width: 50px; }
|
||||
.graybox td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 5px 25px 5px 10px;
|
||||
vertical-align: middle; }
|
||||
.graybox tr td:first-of-type {
|
||||
text-align: right;
|
||||
padding: 7px;
|
||||
vertical-align: top;
|
||||
word-break: normal;
|
||||
width: 40px; }
|
||||
|
||||
.slightly-smaller {
|
||||
font-size: 0.9em; }
|
||||
|
||||
.footer {
|
||||
padding: 8px 16px;
|
||||
background: #444;
|
||||
color: #ddd;
|
||||
font-size: 0.8em; }
|
||||
.footer p {
|
||||
margin: 8px 0; }
|
||||
.footer a {
|
||||
color: #fff; }
|
||||
|
||||
html.dash .header, html.dash .breadcrumbs, html.dash .navigation {
|
||||
display: none; }
|
||||
html.dash .height-container {
|
||||
display: block; }
|
||||
|
||||
form[role=search] input {
|
||||
font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 24px;
|
||||
padding: 0 10px;
|
||||
margin: 0;
|
||||
border: none;
|
||||
border-radius: 1em; }
|
||||
.loading form[role=search] input {
|
||||
background: white url(../img/spinner.gif) center right 4px no-repeat; }
|
||||
form[role=search] .tt-menu {
|
||||
margin: 0;
|
||||
min-width: 300px;
|
||||
background: #fbfbfb;
|
||||
color: #333;
|
||||
border: 1px solid #ddd; }
|
||||
form[role=search] .tt-highlight {
|
||||
font-weight: bold; }
|
||||
form[role=search] .tt-suggestion {
|
||||
font: 16px/1.7 "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
padding: 0 8px; }
|
||||
form[role=search] .tt-suggestion span {
|
||||
display: table-cell;
|
||||
white-space: nowrap; }
|
||||
form[role=search] .tt-suggestion .doc-parent-name {
|
||||
width: 100%;
|
||||
text-align: right;
|
||||
font-weight: normal;
|
||||
font-size: 0.9em;
|
||||
padding-left: 16px; }
|
||||
form[role=search] .tt-suggestion:hover,
|
||||
form[role=search] .tt-suggestion.tt-cursor {
|
||||
cursor: pointer;
|
||||
background-color: #4183c4;
|
||||
color: #fff; }
|
||||
form[role=search] .tt-suggestion:hover .doc-parent-name,
|
||||
form[role=search] .tt-suggestion.tt-cursor .doc-parent-name {
|
||||
color: #fff; }
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.jazzy.http</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>HTTP</string>
|
||||
<key>DocSetPlatformFamily</key>
|
||||
<string>http</string>
|
||||
<key>isDashDocset</key>
|
||||
<true/>
|
||||
<key>dashIndexFilePath</key>
|
||||
<string>index.html</string>
|
||||
<key>isJavaScriptEnabled</key>
|
||||
<true/>
|
||||
<key>DashDocSetFamily</key>
|
||||
<string>dashtoc</string>
|
||||
</dict>
|
||||
</plist>
|
||||
+417
@@ -0,0 +1,417 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>BlueSocketConnectionListener Class Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Class/BlueSocketConnectionListener" class="dashAnchor"></a>
|
||||
|
||||
<a title="BlueSocketConnectionListener Class Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(99% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
BlueSocketConnectionListener Class Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Classes.html">Other Classes</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/BlueSocketConnectionListener.html">BlueSocketConnectionListener</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/BlueSocketSimpleServer.html">BlueSocketSimpleServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Extensions.html">Other Extensions</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Extensions/UnsafeRawBufferPointer.html">UnsafeRawBufferPointer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Protocols.html">Other Protocols</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>BlueSocketConnectionListener</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">BlueSocketConnectionListener</span><span class="p">:</span> <span class="kt">ParserConnecting</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>The Interface between the StreamingParser class and IBM’s BlueSocket wrapper around socket(2).
|
||||
You hopefully should be able to replace this with any network library/engine.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerCAC0C0ADC6socket_AA15StreamingParserC6parserSo13DispatchQueueC04readK0AK05writeK0tcfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init(socket:parser:readQueue:writeQueue:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerCAC0C0ADC6socket_AA15StreamingParserC6parserSo13DispatchQueueC04readK0AK05writeK0tcfc">init(socket:parser:readQueue:writeQueue:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>initializer</p>
|
||||
|
||||
<ul>
|
||||
<li>Parameters:
|
||||
|
||||
<ul>
|
||||
<li>socket: Socket object from BlueSocket library wrapping a socket(2)</li>
|
||||
<li>parser: Manager of the CHTTPParser library</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">socket</span><span class="p">:</span> <span class="kt">Socket</span><span class="p">,</span> <span class="nv">parser</span><span class="p">:</span> <span class="kt">StreamingParser</span><span class="p">,</span> <span class="nv">readQueue</span><span class="p">:</span> <span class="kt">DispatchQueue</span><span class="p">,</span> <span class="nv">writeQueue</span><span class="p">:</span> <span class="kt">DispatchQueue</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC6isOpenSbv"></a>
|
||||
<a name="//apple_ref/swift/Property/isOpen" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC6isOpenSbv">isOpen</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Check if socket is still open. Used to decide whether it should be closed/pruned after timeout</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">isOpen</span><span class="p">:</span> <span class="kt">Bool</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC11closeWriteryyF"></a>
|
||||
<a name="//apple_ref/swift/Method/closeWriter()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC11closeWriteryyF">closeWriter()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Called by the parser to let us know that it’s done with this socket</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">closeWriter</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC17responseBeginningyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/responseBeginning()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC17responseBeginningyyF">responseBeginning()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Called by the parser to let us know that a response has started being created</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">responseBeginning</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC16responseCompleteyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/responseComplete()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC16responseCompleteyyF">responseComplete()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Called by the parser to let us know that a response is complete, and we can close after timeout</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">responseComplete</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC7processyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/process()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC7processyyF">process()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Starts reading from the socket and feeding that data to the parser</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">process</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC05queueC5Writey10Foundation4DataVF"></a>
|
||||
<a name="//apple_ref/swift/Method/queueSocketWrite(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC05queueC5Writey10Foundation4DataVF">queueSocketWrite(_:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Called by the parser to give us data to send back out of the socket</p>
|
||||
|
||||
<div class="aside aside-parameter">
|
||||
<p class="aside-title">Parameter</p>
|
||||
Parameter bytes: Data object to be queued to be written to the socket
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">queueSocketWrite</span><span class="p">(</span><span class="n">_</span> <span class="nv">bytes</span><span class="p">:</span> <span class="kt">Data</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC5writey10Foundation4DataVF"></a>
|
||||
<a name="//apple_ref/swift/Method/write(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC5writey10Foundation4DataVF">write(_:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Write data to a socket. Should be called in an <code>async</code> block on the <code>socketWriterQueue</code></p>
|
||||
|
||||
<div class="aside aside-parameter">
|
||||
<p class="aside-title">Parameter</p>
|
||||
Parameter data: data to be written
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">write</span><span class="p">(</span><span class="n">_</span> <span class="nv">data</span><span class="p">:</span><span class="kt">Data</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-08-23)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,326 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>BlueSocketSimpleServer Class Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Class/BlueSocketSimpleServer" class="dashAnchor"></a>
|
||||
|
||||
<a title="BlueSocketSimpleServer Class Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(99% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
BlueSocketSimpleServer Class Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Classes.html">Other Classes</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/BlueSocketConnectionListener.html">BlueSocketConnectionListener</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/BlueSocketSimpleServer.html">BlueSocketSimpleServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Extensions.html">Other Extensions</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Extensions/UnsafeRawBufferPointer.html">UnsafeRawBufferPointer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Protocols.html">Other Protocols</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>BlueSocketSimpleServer</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">BlueSocketSimpleServer</span> <span class="p">:</span> <span class="kt">CurrentConnectionCounting</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>An HTTP server that listens for connections on a TCP socket and spawns Listeners to handle them.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP22BlueSocketSimpleServerC4portSiv"></a>
|
||||
<a name="//apple_ref/swift/Property/port" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP22BlueSocketSimpleServerC4portSiv">port</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The port we’re listening on. Used primarily to query a randomly assigned port during XCTests</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">port</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP22BlueSocketSimpleServerCACycfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP22BlueSocketSimpleServerCACycfc">init()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Undocumented</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">BlueSocketSimpleServer</span> <span class="p">:</span> <span class="kt">CurrentConnectionCounting</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP22BlueSocketSimpleServerC5startySi4port_Si10queueCountSi06acceptI0AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF"></a>
|
||||
<a name="//apple_ref/swift/Method/start(port:queueCount:acceptCount:handler:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP22BlueSocketSimpleServerC5startySi4port_Si10queueCountSi06acceptI0AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF">start(port:queueCount:acceptCount:handler:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Starts the server listening on a given port</p>
|
||||
|
||||
<p><li>Parameters:</p>
|
||||
|
||||
<p><ul>
|
||||
<li>port: TCP port. See listen(2)</li>
|
||||
<li>handler: Function that creates the HTTP Response from the HTTP Request</li>
|
||||
</ul></li>
|
||||
<div class="aside aside-throws">
|
||||
<p class="aside-title">Throws</p>
|
||||
Error (usually a socket error) generated</p>
|
||||
|
||||
<p></div></p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">start</span><span class="p">(</span><span class="nv">port</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">queueCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">acceptCount</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">handler</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="kt"><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></span><span class="p">)</span> <span class="k">throws</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP22BlueSocketSimpleServerC4stopyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/stop()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP22BlueSocketSimpleServerC4stopyyF">stop()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Stop the server and close the sockets</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">stop</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP22BlueSocketSimpleServerC15connectionCountSiv"></a>
|
||||
<a name="//apple_ref/swift/Property/connectionCount" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP22BlueSocketSimpleServerC15connectionCountSiv">connectionCount</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Count the connections - can be used in XCTests</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">connectionCount</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-08-23)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,301 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPServer Class Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Class/HTTPServer" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPServer Class Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPServer Class Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPServer</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">HTTPServer</span><span class="p">:</span> <span class="kt"><a href="../Protocols/HTTPServing.html">HTTPServing</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>A basic HTTP server. Currently this is implemented using the PoCSocket
|
||||
abstraction, but the intention is to remove this dependency and reimplement
|
||||
the class using transport APIs provided by the Server APIs working group.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPServerCACycfc"></a>
|
||||
<a name="//apple_ref/swift/Method/init()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPServerCACycfc">init()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Create an instance of the server. This needs to be followed with a call to <code><a href="../Classes/HTTPServer.html#/s:4HTTP10HTTPServerC5startySi4port_AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF">start(port:handler:)</a></code></p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPServerC5startySi4port_AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF"></a>
|
||||
<a name="//apple_ref/swift/Method/start(port:handler:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPServerC5startySi4port_AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF">start(port:handler:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Start the HTTP server on the given <code><a href="../Classes/HTTPServer.html#/s:4HTTP10HTTPServerC4portSiv">port</a></code> number, using a <code><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></code> to process incoming requests.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">start</span><span class="p">(</span><span class="nv">port</span><span class="p">:</span> <span class="kt">Int</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="nv">handler</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="kt"><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></span><span class="p">)</span> <span class="k">throws</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPServerC4stopyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/stop()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPServerC4stopyyF">stop()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Stop the server</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">stop</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPServerC4portSiv"></a>
|
||||
<a name="//apple_ref/swift/Property/port" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPServerC4portSiv">port</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The port number the server is listening on</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">port</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPServerC15connectionCountSiv"></a>
|
||||
<a name="//apple_ref/swift/Property/connectionCount" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPServerC15connectionCountSiv">connectionCount</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The number of current connections</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">connectionCount</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,286 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPBodyChunk Enum Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Enum/HTTPBodyChunk" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPBodyChunk Enum Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPBodyChunk Enum Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPBodyChunk</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">HTTPBodyChunk</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>Part or all of the incoming request body</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP13HTTPBodyChunkO5chunkAC8Dispatch0E4DataV4data_yyc18finishedProcessingtcACmF"></a>
|
||||
<a name="//apple_ref/swift/Element/chunk" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP13HTTPBodyChunkO5chunkAC8Dispatch0E4DataV4data_yyc18finishedProcessingtcACmF">chunk</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>A new chunk of the incoming HTTP reqest body data has arrived. <code>finishedProcessing()</code> must be called when
|
||||
that chunk has been processed.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="nf">chunk</span><span class="p">(</span><span class="nv">data</span><span class="p">:</span> <span class="kt">DispatchData</span><span class="p">,</span> <span class="nv">finishedProcessing</span><span class="p">:</span> <span class="p">()</span> <span class="o">-></span> <span class="kt">Void</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP13HTTPBodyChunkO6failedACs5Error_p5error_tcACmF"></a>
|
||||
<a name="//apple_ref/swift/Element/failed" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP13HTTPBodyChunkO6failedACs5Error_p5error_tcACmF">failed</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>An error has occurred whilst streaming the incoming HTTP request data, eg. the connection closed</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="nf">failed</span><span class="p">(</span><span class="nv">error</span><span class="p">:</span> <span class="kt">Error</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP13HTTPBodyChunkO7trailerACSS3key_SS5valuetcACmF"></a>
|
||||
<a name="//apple_ref/swift/Element/trailer" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP13HTTPBodyChunkO7trailerACSS3key_SS5valuetcACmF">trailer</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>A trailer header has arrived during the processing of the incoming HTTP request data.
|
||||
This is currently unimplemented.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="nf">trailer</span><span class="p">(</span><span class="nv">key</span><span class="p">:</span> <span class="kt">String</span><span class="p">,</span> <span class="nv">value</span><span class="p">:</span> <span class="kt">String</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP13HTTPBodyChunkO3endA2CmF"></a>
|
||||
<a name="//apple_ref/swift/Element/end" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP13HTTPBodyChunkO3endA2CmF">end</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The stream of incoming HTTP request data has completed.</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="n">end</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,222 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPBodyProcessing Enum Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Enum/HTTPBodyProcessing" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPBodyProcessing Enum Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPBodyProcessing Enum Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPBodyProcessing</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">HTTPBodyProcessing</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>Indicates whether the body is going to be processed or ignored</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPBodyProcessingO11discardBodyA2CmF"></a>
|
||||
<a name="//apple_ref/swift/Element/discardBody" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPBodyProcessingO11discardBodyA2CmF">discardBody</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Used to discard the body data associated with the incoming HTTP request</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="n">discardBody</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPBodyProcessingO11processBodyACyAA0B5ChunkO_Sbztc7handler_tcACmF"></a>
|
||||
<a name="//apple_ref/swift/Element/processBody" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPBodyProcessingO11processBodyACyAA0B5ChunkO_Sbztc7handler_tcACmF">processBody</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Used to process the body data associated with the imcoming HTTP request using a <code><a href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a></code></p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="nf">processBody</span><span class="p">(</span><span class="nv">handler</span><span class="p">:</span> <span class="kt"><a href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,222 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Result Enum Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Enum/Result" class="dashAnchor"></a>
|
||||
|
||||
<a title="Result Enum Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
Result Enum Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>Result</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">Result</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>The result returned as part of a completion handler</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP6ResultO2okA2CmF"></a>
|
||||
<a name="//apple_ref/swift/Element/ok" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP6ResultO2okA2CmF">ok</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The action was successful</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="n">ok</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP6ResultO5errorACs5Error_pcACmF"></a>
|
||||
<a name="//apple_ref/swift/Element/error" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP6ResultO5errorACs5Error_pcACmF">error</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>An error occurred during the processing of the action</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">case</span> <span class="nf">error</span><span class="p">(</span><span class="kt">Error</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>UnsafeRawBufferPointer Extension Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Extension/UnsafeRawBufferPointer" class="dashAnchor"></a>
|
||||
|
||||
<a title="UnsafeRawBufferPointer Extension Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(99% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
UnsafeRawBufferPointer Extension Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Classes.html">Other Classes</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/BlueSocketConnectionListener.html">BlueSocketConnectionListener</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/BlueSocketSimpleServer.html">BlueSocketSimpleServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Extensions.html">Other Extensions</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Extensions/UnsafeRawBufferPointer.html">UnsafeRawBufferPointer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Protocols.html">Other Protocols</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>UnsafeRawBufferPointer</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UnsafeRawBufferPointer</span> <span class="p">:</span> <span class="kt">Collection</span><span class="p">,</span> <span class="kt">RandomAccessCollection</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:s22UnsafeRawBufferPointerV4HTTPE04withA5BytesxxABKcKlF"></a>
|
||||
<a name="//apple_ref/swift/Method/withUnsafeBytes(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:s22UnsafeRawBufferPointerV4HTTPE04withA5BytesxxABKcKlF">withUnsafeBytes(_:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Undocumented</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UnsafeRawBufferPointer</span> <span class="p">:</span> <span class="kt">Collection</span><span class="p">,</span> <span class="kt">RandomAccessCollection</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-08-23)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,223 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTP Headers Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
<script src="js/lunr.min.js" defer></script>
|
||||
<script src="js/typeahead.jquery.js" defer></script>
|
||||
<script src="js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="HTTP Headers Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
HTTP Headers Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTP Headers</h1>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPHeadersV"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPHeaders" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPHeadersV">HTTPHeaders</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Representation of the HTTP headers associated with a <code><a href="Structs/HTTPRequest.html">HTTPRequest</a></code> or <code><a href="Structs/HTTPResponse.html">HTTPResponse</a></code>.
|
||||
Headers are subscriptable using case-insensitive comparison or provide <code>Name</code> constants. eg.</p>
|
||||
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">contentLength</span> <span class="o">=</span> <span class="n">headers</span><span class="p">[</span><span class="s">"content-length"</span><span class="p">]</span>
|
||||
</code></pre>
|
||||
|
||||
<p>or</p>
|
||||
<pre class="highlight swift"><code> <span class="k">let</span> <span class="nv">contentLength</span> <span class="o">=</span> <span class="n">headers</span><span class="p">[</span><span class="o">.</span><span class="n">contentLength</span><span class="p">]</span>
|
||||
</code></pre>
|
||||
|
||||
<a href="Structs/HTTPHeaders.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPHeaders</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPVersionV"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPVersion" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPVersionV">HTTPVersion</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Version number of the HTTP Protocol</p>
|
||||
|
||||
<a href="Structs/HTTPVersion.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPVersion</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,330 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTP Request Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
<script src="js/lunr.min.js" defer></script>
|
||||
<script src="js/typeahead.jquery.js" defer></script>
|
||||
<script src="js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="HTTP Request Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
HTTP Request Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTP Request</h1>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPRequestV"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPRequest" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPRequestV">HTTPRequest</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>A structure representing the headers from a HTTP request, without the body of the request.</p>
|
||||
|
||||
<a href="Structs/HTTPRequest.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPRequest</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP15HTTPBodyHandlera"></a>
|
||||
<a name="//apple_ref/swift/Alias/HTTPBodyHandler" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Method that takes a chunk of request body and is expected to write to the <code><a href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a></code></p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">HTTPBodyHandler</span> <span class="o">=</span> <span class="p">(</span><span class="kt"><a href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a></span><span class="p">,</span> <span class="k">inout</span> <span class="kt">Bool</span><span class="p">)</span> <span class="o">-></span> <span class="kt">Void</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>HTTPBodyChunk</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p><code>HTTPBodyChunk</code> representing some or all of the incoming request body</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>Bool</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>A boolean flag that can be set to true in order to prevent further processing</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPBodyProcessingO"></a>
|
||||
<a name="//apple_ref/swift/Enum/HTTPBodyProcessing" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPBodyProcessingO">HTTPBodyProcessing</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Indicates whether the body is going to be processed or ignored</p>
|
||||
|
||||
<a href="Enums/HTTPBodyProcessing.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">HTTPBodyProcessing</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP13HTTPBodyChunkO"></a>
|
||||
<a name="//apple_ref/swift/Enum/HTTPBodyChunk" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP13HTTPBodyChunkO">HTTPBodyChunk</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Part or all of the incoming request body</p>
|
||||
|
||||
<a href="Enums/HTTPBodyChunk.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">HTTPBodyChunk</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPMethodV"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPMethod" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPMethodV">HTTPMethod</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>HTTP method structure</p>
|
||||
|
||||
<a href="Structs/HTTPMethod.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPMethod</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,245 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTP Response Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
<script src="js/lunr.min.js" defer></script>
|
||||
<script src="js/typeahead.jquery.js" defer></script>
|
||||
<script src="js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="HTTP Response Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
HTTP Response Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTP Response</h1>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP12HTTPResponseV"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPResponse" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP12HTTPResponseV">HTTPResponse</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>A structure representing the headers for a HTTP response, without the body of the response.</p>
|
||||
|
||||
<a href="Structs/HTTPResponse.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPResponse</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseStatusV"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPResponseStatus" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseStatusV">HTTPResponseStatus</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The response status for the HTTP response</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<a href="https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml">https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml</a> for more information
|
||||
|
||||
</div>
|
||||
|
||||
<a href="Structs/HTTPResponseStatus.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">struct</span> <span class="kt">HTTPResponseStatus</span><span class="p">:</span> <span class="kt">Equatable</span><span class="p">,</span> <span class="kt">CustomStringConvertible</span><span class="p">,</span> <span class="kt">ExpressibleByIntegerLiteral</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterP"></a>
|
||||
<a name="//apple_ref/swift/Protocol/HTTPResponseWriter" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterP">HTTPResponseWriter</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>HTTPResponseWriter provides functions to create an HTTP response</p>
|
||||
|
||||
<a href="Protocols/HTTPResponseWriter.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">HTTPResponseWriter</span> <span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,329 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTP Server Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
<script src="js/lunr.min.js" defer></script>
|
||||
<script src="js/typeahead.jquery.js" defer></script>
|
||||
<script src="js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="HTTP Server Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
HTTP Server Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTP Server</h1>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPServerC"></a>
|
||||
<a name="//apple_ref/swift/Class/HTTPServer" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPServerC">HTTPServer</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>A basic HTTP server. Currently this is implemented using the PoCSocket
|
||||
abstraction, but the intention is to remove this dependency and reimplement
|
||||
the class using transport APIs provided by the Server APIs working group.</p>
|
||||
|
||||
<a href="Classes/HTTPServer.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">HTTPServer</span><span class="p">:</span> <span class="kt"><a href="Protocols/HTTPServing.html">HTTPServing</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPServingP"></a>
|
||||
<a name="//apple_ref/swift/Protocol/HTTPServing" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPServingP">HTTPServing</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Definition of an HTTP server.</p>
|
||||
|
||||
<a href="Protocols/HTTPServing.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">HTTPServing</span> <span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPRequestHandlera"></a>
|
||||
<a name="//apple_ref/swift/Alias/HTTPRequestHandler" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Typealias for a closure that handles an incoming HTTP request
|
||||
The following is an example of an echo <code>HTTPRequestHandler</code> that returns the request it receives as a response:</p>
|
||||
<pre class="highlight swift"><code> <span class="kd">func</span> <span class="nf">echo</span><span class="p">(</span><span class="nv">request</span><span class="p">:</span> <span class="kt">HTTPRequest</span><span class="p">,</span> <span class="nv">response</span><span class="p">:</span> <span class="kt">HTTPResponseWriter</span> <span class="p">)</span> <span class="o">-></span> <span class="kt">HTTPBodyProcessing</span> <span class="p">{</span>
|
||||
<span class="n">response</span><span class="o">.</span><span class="nf">writeHeader</span><span class="p">(</span><span class="nv">status</span><span class="p">:</span> <span class="o">.</span><span class="n">ok</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="o">.</span><span class="n">processBody</span> <span class="p">{</span> <span class="p">(</span><span class="n">chunk</span><span class="p">,</span> <span class="n">stop</span><span class="p">)</span> <span class="k">in</span>
|
||||
<span class="k">switch</span> <span class="n">chunk</span> <span class="p">{</span>
|
||||
<span class="k">case</span> <span class="o">.</span><span class="nf">chunk</span><span class="p">(</span><span class="k">let</span> <span class="nv">data</span><span class="p">,</span> <span class="k">let</span> <span class="nv">finishedProcessing</span><span class="p">):</span>
|
||||
<span class="n">response</span><span class="o">.</span><span class="nf">writeBody</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="p">{</span> <span class="n">_</span> <span class="k">in</span>
|
||||
<span class="nf">finishedProcessing</span><span class="p">()</span>
|
||||
<span class="p">}</span>
|
||||
<span class="k">case</span> <span class="o">.</span><span class="nv">end</span><span class="p">:</span>
|
||||
<span class="n">response</span><span class="o">.</span><span class="nf">done</span><span class="p">()</span>
|
||||
<span class="k">default</span><span class="p">:</span>
|
||||
<span class="n">stop</span> <span class="o">=</span> <span class="kc">true</span>
|
||||
<span class="n">response</span><span class="o">.</span><span class="nf">abort</span><span class="p">()</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre>
|
||||
|
||||
<p>This then needs to be registered with the server using <code><a href="Classes/HTTPServer.html#/s:4HTTP10HTTPServerC5startySi4port_AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF">HTTPServer.start(port:handler:)</a></code></p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">typealias</span> <span class="kt">HTTPRequestHandler</span> <span class="o">=</span> <span class="p">(</span><span class="kt"><a href="Structs/HTTPRequest.html">HTTPRequest</a></span><span class="p">,</span> <span class="kt"><a href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>req</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>the incoming HTTP request.</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>res</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>a writer providing functions to create an HTTP reponse to the request.</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP19HTTPRequestHandlingP"></a>
|
||||
<a name="//apple_ref/swift/Protocol/HTTPRequestHandling" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP19HTTPRequestHandlingP">HTTPRequestHandling</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Class protocol containing a <code>handle()</code> function that implements <code><a href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></code> to respond to incoming HTTP requests.</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<code><a href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></code> for more information
|
||||
|
||||
</div>
|
||||
|
||||
<a href="Protocols/HTTPRequestHandling.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">HTTPRequestHandling</span><span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,274 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Other Classes Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="Other Classes Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(99% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
Other Classes Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Classes.html">Other Classes</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/BlueSocketConnectionListener.html">BlueSocketConnectionListener</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/BlueSocketSimpleServer.html">BlueSocketSimpleServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Extensions.html">Other Extensions</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Extensions/UnsafeRawBufferPointer.html">UnsafeRawBufferPointer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Protocols.html">Other Protocols</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>Other Classes</h1>
|
||||
<p>The following classes are available globally.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP10HTTPServerC"></a>
|
||||
<a name="//apple_ref/swift/Class/HTTPServer" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP10HTTPServerC">HTTPServer</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>A basic HTTP server. Currently this is implemented using the BlueSocket
|
||||
abstraction, but the intention is to remove this dependency and reimplement
|
||||
the class using transport APIs provided by the Server APIs working group.</p>
|
||||
|
||||
<a href="Classes/HTTPServer.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">HTTPServer</span> <span class="p">:</span> <span class="kt"><a href="Protocols/HTTPServing.html">HTTPServing</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP28BlueSocketConnectionListenerC"></a>
|
||||
<a name="//apple_ref/swift/Class/BlueSocketConnectionListener" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP28BlueSocketConnectionListenerC">BlueSocketConnectionListener</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The Interface between the StreamingParser class and IBM’s BlueSocket wrapper around socket(2).
|
||||
You hopefully should be able to replace this with any network library/engine.</p>
|
||||
|
||||
<a href="Classes/BlueSocketConnectionListener.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">BlueSocketConnectionListener</span><span class="p">:</span> <span class="kt">ParserConnecting</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<div class="task-name-container">
|
||||
<a name="/Server"></a>
|
||||
<a name="//apple_ref/swift/Section/Server" class="dashAnchor"></a>
|
||||
<a href="#/Server">
|
||||
<h3 class="section-name">Server</h3>
|
||||
</a>
|
||||
</div>
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP22BlueSocketSimpleServerC"></a>
|
||||
<a name="//apple_ref/swift/Class/BlueSocketSimpleServer" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP22BlueSocketSimpleServerC">BlueSocketSimpleServer</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>An HTTP server that listens for connections on a TCP socket and spawns Listeners to handle them.</p>
|
||||
|
||||
<a href="Classes/BlueSocketSimpleServer.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">BlueSocketSimpleServer</span> <span class="p">:</span> <span class="kt">CurrentConnectionCounting</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-08-23)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,185 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Other Enums Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
<script src="js/lunr.min.js" defer></script>
|
||||
<script src="js/typeahead.jquery.js" defer></script>
|
||||
<script src="js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="Other Enums Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
Other Enums Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>Other Enums</h1>
|
||||
<p>The following enums are available globally.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP6ResultO"></a>
|
||||
<a name="//apple_ref/swift/Enum/Result" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP6ResultO">Result</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The result returned as part of a completion handler</p>
|
||||
|
||||
<a href="Enums/Result.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">enum</span> <span class="kt">Result</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,199 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Other Extensions Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="Other Extensions Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(99% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
Other Extensions Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Classes.html">Other Classes</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/BlueSocketConnectionListener.html">BlueSocketConnectionListener</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/BlueSocketSimpleServer.html">BlueSocketSimpleServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Extensions.html">Other Extensions</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Extensions/UnsafeRawBufferPointer.html">UnsafeRawBufferPointer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Protocols.html">Other Protocols</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>Other Extensions</h1>
|
||||
<p>The following extensions are available globally.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:s22UnsafeRawBufferPointerV"></a>
|
||||
<a name="//apple_ref/swift/Extension/UnsafeRawBufferPointer" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:s22UnsafeRawBufferPointerV">UnsafeRawBufferPointer</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
|
||||
<a href="Extensions/UnsafeRawBufferPointer.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">struct</span> <span class="kt">UnsafeRawBufferPointer</span> <span class="p">:</span> <span class="kt">Collection</span><span class="p">,</span> <span class="kt">RandomAccessCollection</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-08-23)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,200 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Other Protocols Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="js/jquery.min.js" defer></script>
|
||||
<script src="js/jazzy.js" defer></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<a title="Other Protocols Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(99% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="index.html">HTTP Reference</a>
|
||||
<img class="carat" src="img/carat.png" />
|
||||
Other Protocols Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Classes.html">Other Classes</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/BlueSocketConnectionListener.html">BlueSocketConnectionListener</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/BlueSocketSimpleServer.html">BlueSocketSimpleServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Extensions.html">Other Extensions</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Extensions/UnsafeRawBufferPointer.html">UnsafeRawBufferPointer</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="Other Protocols.html">Other Protocols</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>Other Protocols</h1>
|
||||
<p>The following protocols are available globally.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPServingP"></a>
|
||||
<a name="//apple_ref/swift/Protocol/HTTPServing" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPServingP">HTTPServing</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Definition of an HTTP server.</p>
|
||||
|
||||
<a href="Protocols/HTTPServing.html" class="slightly-smaller">See more</a>
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">HTTPServing</span> <span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-08-23)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,232 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPRequestHandling Protocol Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Protocol/HTTPRequestHandling" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPRequestHandling Protocol Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPRequestHandling Protocol Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPRequestHandling</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">HTTPRequestHandling</span><span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>Class protocol containing a <code>handle()</code> function that implements <code><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></code> to respond to incoming HTTP requests.</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<code><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></code> for more information
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP19HTTPRequestHandlingP6handleAA18HTTPBodyProcessingOAA0B0V7request_AA18HTTPResponseWriter_p8responsetF"></a>
|
||||
<a name="//apple_ref/swift/Method/handle(request:response:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP19HTTPRequestHandlingP6handleAA18HTTPBodyProcessingOAA0B0V7request_AA18HTTPResponseWriter_p8responsetF">handle(request:response:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>handle: function that implements <code><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></code> and is called when a new HTTP request is received by the HTTP server.</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<code><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></code> for more information
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">handle</span><span class="p">(</span><span class="nv">request</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPRequest.html">HTTPRequest</a></span><span class="p">,</span> <span class="nv">response</span><span class="p">:</span> <span class="kt"><a href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a></span><span class="p">)</span> <span class="o">-></span> <span class="kt"><a href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a></span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>request</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>the incoming HTTP request.</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>response</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>a writer providing functions to create an HTTP response to the request.</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,603 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPResponseWriter Protocol Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Protocol/HTTPResponseWriter" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPResponseWriter Protocol Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPResponseWriter Protocol Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPResponseWriter</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">HTTPResponseWriter</span> <span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>HTTPResponseWriter provides functions to create an HTTP response</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterP11writeHeaderyAA0B6StatusV6status_AA11HTTPHeadersV7headersyAA6ResultOc10completiontF"></a>
|
||||
<a name="//apple_ref/swift/Method/writeHeader(status:headers:completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterP11writeHeaderyAA0B6StatusV6status_AA11HTTPHeadersV7headersyAA6ResultOc10completiontF">writeHeader(status:headers:completion:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Writer function to create the headers for an HTTP response</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">writeHeader</span><span class="p">(</span><span class="nv">status</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a></span><span class="p">,</span> <span class="nv">headers</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPHeaders.html">HTTPHeaders</a></span><span class="p">,</span> <span class="nv">completion</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/Result.html">Result</a></span><span class="p">)</span> <span class="o">-></span> <span class="kt">Void</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>status</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>The status code to include in the HTTP response</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>headers</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>The HTTP headers to include in the HTTP response</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>completion</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>Closure that is called when the HTTP headers have been written to the HTTP respose</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterP12writeTraileryAA11HTTPHeadersV_yAA6ResultOc10completiontF"></a>
|
||||
<a name="//apple_ref/swift/Method/writeTrailer(_:completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterP12writeTraileryAA11HTTPHeadersV_yAA6ResultOc10completiontF">writeTrailer(_:completion:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Writer function to write a trailer header as part of the HTTP response</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">writeTrailer</span><span class="p">(</span><span class="n">_</span> <span class="nv">trailers</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPHeaders.html">HTTPHeaders</a></span><span class="p">,</span> <span class="nv">completion</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/Result.html">Result</a></span><span class="p">)</span> <span class="o">-></span> <span class="kt">Void</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>trailers</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>The trailers to write as part of the HTTP response</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>completion</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>Closure that is called when the trailers has been written to the HTTP response
|
||||
This is not currently implemented</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterP9writeBodyyAA06UnsafebE0_p_yAA6ResultOc10completiontF"></a>
|
||||
<a name="//apple_ref/swift/Method/writeBody(_:completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterP9writeBodyyAA06UnsafebE0_p_yAA6ResultOc10completiontF">writeBody(_:completion:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Writer function to write data to the body of the HTTP response</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">writeBody</span><span class="p">(</span><span class="n">_</span> <span class="nv">data</span><span class="p">:</span> <span class="kt">UnsafeHTTPResponseBody</span><span class="p">,</span> <span class="nv">completion</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/Result.html">Result</a></span><span class="p">)</span> <span class="o">-></span> <span class="kt">Void</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>data</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>The data to write as part of the HTTP response</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>completion</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>Closure that is called when the data has been written to the HTTP response</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterP4doneyyAA6ResultOc10completion_tF"></a>
|
||||
<a name="//apple_ref/swift/Method/done(completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterP4doneyyAA6ResultOc10completion_tF">done(completion:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Writer function to complete the HTTP response</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">done</span><span class="p">(</span><span class="nv">completion</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt"><a href="../Enums/Result.html">Result</a></span><span class="p">)</span> <span class="o">-></span> <span class="kt">Void</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h4>Parameters</h4>
|
||||
<table class="graybox">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
<em>completion</em>
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<p>Closure that is called when the HTTP response has been completed</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterP5abortyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/abort()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterP5abortyyF">abort()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>abort: Abort the HTTP response</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">abort</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterPAAE11writeHeaderyAA0B6StatusV6status_AA11HTTPHeadersV7headerstF"></a>
|
||||
<a name="//apple_ref/swift/Method/writeHeader(status:headers:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterPAAE11writeHeaderyAA0B6StatusV6status_AA11HTTPHeadersV7headerstF">writeHeader(status:headers:)</a>
|
||||
</code>
|
||||
<span class="declaration-note">
|
||||
Extension method
|
||||
</span>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Convenience function to write the headers for an HTTP response without a completion handler</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<code><a href="../Protocols/HTTPResponseWriter.html#/s:4HTTP18HTTPResponseWriterP11writeHeaderyAA0B6StatusV6status_AA11HTTPHeadersV7headersyAA6ResultOc10completiontF">writeHeader(status:headers:completion:)</a></code>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">writeHeader</span><span class="p">(</span><span class="nv">status</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a></span><span class="p">,</span> <span class="nv">headers</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPHeaders.html">HTTPHeaders</a></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterPAAE11writeHeaderyAA0B6StatusV6status_tF"></a>
|
||||
<a name="//apple_ref/swift/Method/writeHeader(status:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterPAAE11writeHeaderyAA0B6StatusV6status_tF">writeHeader(status:)</a>
|
||||
</code>
|
||||
<span class="declaration-note">
|
||||
Extension method
|
||||
</span>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Convenience function to write a HTTP response with no headers or completion handler</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<code><a href="../Protocols/HTTPResponseWriter.html#/s:4HTTP18HTTPResponseWriterP11writeHeaderyAA0B6StatusV6status_AA11HTTPHeadersV7headersyAA6ResultOc10completiontF">writeHeader(status:headers:completion:)</a></code>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">writeHeader</span><span class="p">(</span><span class="nv">status</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterPAAE12writeTraileryAA11HTTPHeadersVF"></a>
|
||||
<a name="//apple_ref/swift/Method/writeTrailer(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterPAAE12writeTraileryAA11HTTPHeadersVF">writeTrailer(_:)</a>
|
||||
</code>
|
||||
<span class="declaration-note">
|
||||
Extension method
|
||||
</span>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Convenience function to write a trailer header as part of the HTTP response without a completion handler</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
<code><a href="../Protocols/HTTPResponseWriter.html#/s:4HTTP18HTTPResponseWriterP12writeTraileryAA11HTTPHeadersV_yAA6ResultOc10completiontF">writeTrailer(_:completion:)</a></code>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">writeTrailer</span><span class="p">(</span><span class="n">_</span> <span class="nv">trailers</span><span class="p">:</span> <span class="kt"><a href="../Structs/HTTPHeaders.html">HTTPHeaders</a></span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterPAAE9writeBodyyAA06UnsafebE0_pF"></a>
|
||||
<a name="//apple_ref/swift/Method/writeBody(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterPAAE9writeBodyyAA06UnsafebE0_pF">writeBody(_:)</a>
|
||||
</code>
|
||||
<span class="declaration-note">
|
||||
Extension method
|
||||
</span>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Convenience function for writing <code>data</code> to the body of the HTTP response without a completion handler.</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
writeBody(_:completion:)
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">writeBody</span><span class="p">(</span><span class="n">_</span> <span class="nv">data</span><span class="p">:</span> <span class="kt">UnsafeHTTPResponseBody</span><span class="p">)</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP18HTTPResponseWriterPAAE4doneyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/done()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP18HTTPResponseWriterPAAE4doneyyF">done()</a>
|
||||
</code>
|
||||
<span class="declaration-note">
|
||||
Extension method
|
||||
</span>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Convenience function to complete the HTTP response without a completion handler.</p>
|
||||
<div class="aside aside-see">
|
||||
<p class="aside-title">See</p>
|
||||
done(completion:)
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">done</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
@@ -0,0 +1,272 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTPServing Protocol Reference</title>
|
||||
<link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../css/highlight.css" />
|
||||
<meta charset="utf-8">
|
||||
<script src="../js/jquery.min.js" defer></script>
|
||||
<script src="../js/jazzy.js" defer></script>
|
||||
|
||||
<script src="../js/lunr.min.js" defer></script>
|
||||
<script src="../js/typeahead.jquery.js" defer></script>
|
||||
<script src="../js/jazzy.search.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a name="//apple_ref/swift/Protocol/HTTPServing" class="dashAnchor"></a>
|
||||
|
||||
<a title="HTTPServing Protocol Reference"></a>
|
||||
|
||||
<header class="header">
|
||||
<p class="header-col header-col--primary">
|
||||
<a class="header-link" href="../index.html">
|
||||
HTTP Docs
|
||||
</a>
|
||||
(100% documented)
|
||||
</p>
|
||||
|
||||
<p class="header-col--secondary">
|
||||
<form role="search" action="../search.json">
|
||||
<input type="text" placeholder="Search documentation" data-typeahead>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<p class="header-col header-col--secondary">
|
||||
<a class="header-link" href="https://github.com/swift-server/http/">
|
||||
<img class="header-icon" src="../img/gh.png"/>
|
||||
View on GitHub
|
||||
</a>
|
||||
</p>
|
||||
|
||||
</header>
|
||||
|
||||
<p class="breadcrumbs">
|
||||
<a class="breadcrumb" href="../index.html">HTTP Reference</a>
|
||||
<img class="carat" src="../img/carat.png" />
|
||||
HTTPServing Protocol Reference
|
||||
</p>
|
||||
|
||||
<div class="content-wrapper">
|
||||
<nav class="navigation">
|
||||
<ul class="nav-groups">
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Server.html">HTTP Server</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Classes/HTTPServer.html">HTTPServer</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPServing.html">HTTPServing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPRequestHandling.html">HTTPRequestHandling</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Headers.html">HTTP Headers</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders.html">HTTPHeaders</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPHeaders/Name.html">– Name</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPVersion.html">HTTPVersion</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Request.html">HTTP Request</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPRequest.html">HTTPRequest</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPMethod.html">HTTPMethod</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../HTTP Request.html#/s:4HTTP15HTTPBodyHandlera">HTTPBodyHandler</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyProcessing.html">HTTPBodyProcessing</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/HTTPBodyChunk.html">HTTPBodyChunk</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../HTTP Response.html">HTTP Response</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponse.html">HTTPResponse</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus.html">HTTPResponseStatus</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Structs/HTTPResponseStatus/Class.html">– Class</a>
|
||||
</li>
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Protocols/HTTPResponseWriter.html">HTTPResponseWriter</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-group-name">
|
||||
<a class="nav-group-name-link" href="../Other Enums.html">Other Enums</a>
|
||||
<ul class="nav-group-tasks">
|
||||
<li class="nav-group-task">
|
||||
<a class="nav-group-task-link" href="../Enums/Result.html">Result</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<article class="main-content">
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<h1>HTTPServing</h1>
|
||||
<div class="declaration">
|
||||
<div class="language">
|
||||
<pre class="highlight"><code><span class="kd">public</span> <span class="kd">protocol</span> <span class="kt">HTTPServing</span> <span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<p>Definition of an HTTP server.</p>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<div class="section-content">
|
||||
<div class="task-group">
|
||||
<ul class="item-container">
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPServingP5startySi4port_AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF"></a>
|
||||
<a name="//apple_ref/swift/Method/start(port:handler:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPServingP5startySi4port_AA18HTTPBodyProcessingOAA11HTTPRequestV_AA18HTTPResponseWriter_ptc7handlertKF">start(port:handler:)</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Start the HTTP server on the given <code><a href="../Protocols/HTTPServing.html#/s:4HTTP11HTTPServingP4portSiv">port</a></code>, using <code>handler</code> to process incoming requests</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">start</span><span class="p">(</span><span class="nv">port</span><span class="p">:</span> <span class="kt">Int</span><span class="p">,</span> <span class="nv">handler</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="kt"><a href="../HTTP Server.html#/s:4HTTP18HTTPRequestHandlera">HTTPRequestHandler</a></span><span class="p">)</span> <span class="k">throws</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPServingP4stopyyF"></a>
|
||||
<a name="//apple_ref/swift/Method/stop()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPServingP4stopyyF">stop()</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>Stop the server</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="kd">func</span> <span class="nf">stop</span><span class="p">()</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPServingP4portSiv"></a>
|
||||
<a name="//apple_ref/swift/Property/port" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPServingP4portSiv">port</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The port the server is listening on</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">var</span> <span class="nv">port</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP11HTTPServingP15connectionCountSiv"></a>
|
||||
<a name="//apple_ref/swift/Property/connectionCount" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP11HTTPServingP15connectionCountSiv">connectionCount</a>
|
||||
</code>
|
||||
</div>
|
||||
<div class="height-container">
|
||||
<div class="pointer-container"></div>
|
||||
<section class="section">
|
||||
<div class="pointer"></div>
|
||||
<div class="abstract">
|
||||
<p>The number of current connections</p>
|
||||
|
||||
</div>
|
||||
<div class="declaration">
|
||||
<h4>Declaration</h4>
|
||||
<div class="language">
|
||||
<p class="aside-title">Swift</p>
|
||||
<pre class="highlight"><code><span class="k">var</span> <span class="nv">connectionCount</span><span class="p">:</span> <span class="kt">Int</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<section class="footer">
|
||||
<p>© 2017 <a class="link" href="" target="_blank" rel="external">Swift Server API project</a>. All rights reserved. (Last updated: 2017-10-02)</p>
|
||||
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
|
||||
</section>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user