Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f8516cc725 | |||
| 811940bb05 | |||
| 3aa8b03c06 | |||
| 2ab754e00f | |||
| defd4c7005 | |||
| d81bed005d | |||
| 00adc53d0f | |||
| 280caad31d | |||
| 327e890e55 | |||
| a8205d2b7a | |||
| 62aba99de0 | |||
| ee4b4d9620 | |||
| fee5702695 | |||
| 055a757e15 | |||
| 6b5b27edf0 | |||
| d53f9432ce | |||
| 8d278305c1 | |||
| 75f022c06d | |||
| 6c0317d239 | |||
| 0a09bcac28 | |||
| ab8f280798 | |||
| 92f3ee4dc0 |
@@ -73,3 +73,4 @@ fastlane/test_output
|
||||
*.orig
|
||||
/.idea
|
||||
/Package.pins
|
||||
docs
|
||||
|
||||
@@ -12,14 +12,16 @@ readme: README.md
|
||||
skip_undocumented: false
|
||||
hide_documentation_coverage: false
|
||||
|
||||
xcodebuild_arguments: [-project, SwiftServerHTTP.xcodeproj, -target, HTTP, LIBRARY_SEARCH_PATHS=.build/debug]
|
||||
xcodebuild_arguments: [-project, SwiftServerHTTP.xcodeproj, -target, HTTP]
|
||||
|
||||
custom_categories:
|
||||
|
||||
- name: HTTP Server
|
||||
children:
|
||||
- WebAppContaining
|
||||
- WebApp
|
||||
- HTTPServer
|
||||
- HTTPServing
|
||||
- HTTPRequestHandler
|
||||
- HTTPRequestHandling
|
||||
|
||||
- name: HTTP Headers
|
||||
children:
|
||||
|
||||
@@ -1 +1 @@
|
||||
3.1.1-RELEASE
|
||||
4.0
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
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
|
||||
@@ -0,0 +1,24 @@
|
||||
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,20 +1,31 @@
|
||||
// swift-tools-version:3.1
|
||||
// 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",
|
||||
targets: [
|
||||
Target(name: "HTTP"),
|
||||
Target(name: "BlueSocketHTTP", dependencies: ["HTTP"]),
|
||||
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: [
|
||||
.Package(url: "https://github.com/IBM-Swift/CHTTPParser.git", majorVersion: 0, minor: 4),
|
||||
.Package(url: "https://github.com/IBM-Swift/BlueSocket.git", majorVersion: 0, minor: 12),
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
// .package(url: /* package url */, from: "1.0.0"),
|
||||
],
|
||||
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"]),
|
||||
.testTarget(
|
||||
name: "HTTPTests",
|
||||
dependencies: ["HTTP"]),
|
||||
]
|
||||
)
|
||||
|
||||
#if os(Linux)
|
||||
package.dependencies.append(
|
||||
.Package(url: "https://github.com/IBM-Swift/BlueSignals.git", majorVersion: 0, minor: 9))
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,74 @@
|
||||
# SwiftServerHttp
|
||||
# Swift Server Project HTTP APIs
|
||||
|
||||
Sample prototype implementation of @weissi's HTTP Sketch v2 from https://lists.swift.org/pipermail/swift-server-dev/Week-of-Mon-20170403/000422.html for discussion.
|
||||
This is an early implementation of the Swift Server Project's HTTP APIs. This provides simple HTTP server on which rich web application frameworks can be built.
|
||||
|
||||
## 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)
|
||||
|
||||
CFRunLoopRun()
|
||||
```
|
||||
|
||||
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)
|
||||
|
||||
CFRunLoopRun()
|
||||
```
|
||||
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/>
|
||||
|
||||
|
||||
## 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,275 +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
|
||||
|
||||
import Socket
|
||||
|
||||
#if os(Linux)
|
||||
import Signals
|
||||
import Dispatch
|
||||
#endif
|
||||
|
||||
|
||||
/// 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.
|
||||
public class BlueSocketConnectionListener: ParserConnecting {
|
||||
var socket: Socket?
|
||||
|
||||
///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
|
||||
|
||||
/// Queues for managing access to the socket without blocking the world
|
||||
weak var socketReaderQueue: DispatchQueue?
|
||||
weak var 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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// initializer
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - socket: Socket object from BlueSocket library wrapping a socket(2)
|
||||
/// - parser: Manager of the CHTTPParser library
|
||||
public init(socket: Socket, parser: StreamingParser, readQueue: DispatchQueue, writeQueue: DispatchQueue) {
|
||||
self.socket = socket
|
||||
socketFD = socket.socketfd
|
||||
socketReaderQueue = readQueue
|
||||
socketWriterQueue = writeQueue
|
||||
self.parser = parser
|
||||
parser.parserConnector = self
|
||||
}
|
||||
|
||||
|
||||
/// Check if socket is still open. Used to decide whether it should be closed/pruned after timeout
|
||||
public var isOpen: Bool {
|
||||
guard let socket = self.socket else {
|
||||
return false
|
||||
}
|
||||
return (socket.isActive || socket.isConnected)
|
||||
}
|
||||
|
||||
|
||||
/// Close the socket and free up memory unless we're in the middle of a request
|
||||
func close() {
|
||||
if !self.responseCompleted && !self.errorOccurred {
|
||||
return
|
||||
}
|
||||
if (self.socket?.socketfd ?? -1) > 0 {
|
||||
self.socket?.close()
|
||||
}
|
||||
|
||||
//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) {
|
||||
self.readerSource?.cancel()
|
||||
}
|
||||
self.readerSource?.setEventHandler(handler: nil)
|
||||
self.readerSource?.setCancelHandler(handler: nil)
|
||||
|
||||
self.readerSource = nil
|
||||
self.socket = nil
|
||||
self.parser?.parserConnector = nil //allows for memory to be reclaimed
|
||||
self.parser = nil
|
||||
self.socketReaderQueue = nil
|
||||
self.socketWriterQueue = nil
|
||||
}
|
||||
|
||||
|
||||
/// 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() {
|
||||
let now = Date().timeIntervalSinceReferenceDate
|
||||
if let keepAliveUntil = parser?.keepAliveUntil, now >= keepAliveUntil {
|
||||
print("Closing idle socket \(socketFD)")
|
||||
close()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Called by the parser to let us know that a response has started being created
|
||||
public func responseBeginning() {
|
||||
self.socketWriterQueue?.async { [weak self] in
|
||||
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.socketWriterQueue?.async { [weak self] in
|
||||
self?.responseCompleted = true
|
||||
if (self?.readerSource?.isCancelled ?? true) {
|
||||
self?.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Starts reading from the socket and feeding that data to the parser
|
||||
public func process() {
|
||||
do {
|
||||
try! socket?.setBlocking(mode: true)
|
||||
|
||||
let tempReaderSource = DispatchSource.makeReadSource(fileDescriptor: socket?.socketfd ?? -1,
|
||||
queue: socketReaderQueue)
|
||||
|
||||
tempReaderSource.setEventHandler { [weak self] in
|
||||
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
guard strongSelf.socket?.socketfd ?? -1 > 0 else {
|
||||
self?.readerSource?.cancel()
|
||||
return
|
||||
}
|
||||
|
||||
var length = 1 //initial value
|
||||
do {
|
||||
repeat {
|
||||
if strongSelf.socket?.socketfd ?? -1 > 0 {
|
||||
let readBuffer:NSMutableData = NSMutableData()
|
||||
length = try strongSelf.socket?.read(into: readBuffer) ?? -1
|
||||
if length > 0 {
|
||||
self?.responseCompleted = false
|
||||
}
|
||||
let data = Data(bytes:readBuffer.bytes.assumingMemoryBound(to: Int8.self), count:readBuffer.length)
|
||||
|
||||
let numberParsed = strongSelf.parser?.readStream(data:data) ?? 0
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
} while length > 0
|
||||
} catch {
|
||||
print("ReaderSource Event Error: \(error)")
|
||||
self?.readerSource?.cancel()
|
||||
self?.errorOccurred = true
|
||||
self?.close()
|
||||
}
|
||||
if (length == 0) {
|
||||
self?.readerSource?.cancel()
|
||||
}
|
||||
if (length < 0) {
|
||||
self?.errorOccurred = true
|
||||
self?.readerSource?.cancel()
|
||||
self?.close()
|
||||
}
|
||||
}
|
||||
|
||||
tempReaderSource.setCancelHandler { [ weak self] in
|
||||
self?.close() //close if we can
|
||||
}
|
||||
|
||||
self.readerSource = tempReaderSource
|
||||
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) {
|
||||
self.socketWriterQueue?.async { [ weak self ] in
|
||||
self?.write(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// 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
|
||||
let result = try socket?.write(from: ptr + offset, bufSize:
|
||||
data.count - offset) ?? -1
|
||||
if (result < 0) {
|
||||
print("Recived broken write socket indication")
|
||||
errorOccurred = true
|
||||
} else {
|
||||
written += result
|
||||
}
|
||||
}
|
||||
offset = data.count - written
|
||||
}
|
||||
if (errorOccurred) {
|
||||
close()
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
print("Recived write socket error: \(error)")
|
||||
errorOccurred = true
|
||||
close()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,431 @@
|
||||
/* 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 <stddef.h>
|
||||
#if defined(_WIN32) && !defined(__MINGW32__) && \
|
||||
(!defined(_MSC_VER) || _MSC_VER<1600) && !defined(__WINE__)
|
||||
#include <BaseTsd.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*);
|
||||
|
||||
|
||||
/* Status Codes */
|
||||
#define HTTP_STATUS_MAP(XX) \
|
||||
XX(100, CONTINUE, Continue) \
|
||||
XX(101, SWITCHING_PROTOCOLS, Switching Protocols) \
|
||||
XX(102, PROCESSING, Processing) \
|
||||
XX(200, OK, OK) \
|
||||
XX(201, CREATED, Created) \
|
||||
XX(202, ACCEPTED, Accepted) \
|
||||
XX(203, NON_AUTHORITATIVE_INFORMATION, Non-Authoritative Information) \
|
||||
XX(204, NO_CONTENT, No Content) \
|
||||
XX(205, RESET_CONTENT, Reset Content) \
|
||||
XX(206, PARTIAL_CONTENT, Partial Content) \
|
||||
XX(207, MULTI_STATUS, Multi-Status) \
|
||||
XX(208, ALREADY_REPORTED, Already Reported) \
|
||||
XX(226, IM_USED, IM Used) \
|
||||
XX(300, MULTIPLE_CHOICES, Multiple Choices) \
|
||||
XX(301, MOVED_PERMANENTLY, Moved Permanently) \
|
||||
XX(302, FOUND, Found) \
|
||||
XX(303, SEE_OTHER, See Other) \
|
||||
XX(304, NOT_MODIFIED, Not Modified) \
|
||||
XX(305, USE_PROXY, Use Proxy) \
|
||||
XX(307, TEMPORARY_REDIRECT, Temporary Redirect) \
|
||||
XX(308, PERMANENT_REDIRECT, Permanent Redirect) \
|
||||
XX(400, BAD_REQUEST, Bad Request) \
|
||||
XX(401, UNAUTHORIZED, Unauthorized) \
|
||||
XX(402, PAYMENT_REQUIRED, Payment Required) \
|
||||
XX(403, FORBIDDEN, Forbidden) \
|
||||
XX(404, NOT_FOUND, Not Found) \
|
||||
XX(405, METHOD_NOT_ALLOWED, Method Not Allowed) \
|
||||
XX(406, NOT_ACCEPTABLE, Not Acceptable) \
|
||||
XX(407, PROXY_AUTHENTICATION_REQUIRED, Proxy Authentication Required) \
|
||||
XX(408, REQUEST_TIMEOUT, Request Timeout) \
|
||||
XX(409, CONFLICT, Conflict) \
|
||||
XX(410, GONE, Gone) \
|
||||
XX(411, LENGTH_REQUIRED, Length Required) \
|
||||
XX(412, PRECONDITION_FAILED, Precondition Failed) \
|
||||
XX(413, PAYLOAD_TOO_LARGE, Payload Too Large) \
|
||||
XX(414, URI_TOO_LONG, URI Too Long) \
|
||||
XX(415, UNSUPPORTED_MEDIA_TYPE, Unsupported Media Type) \
|
||||
XX(416, RANGE_NOT_SATISFIABLE, Range Not Satisfiable) \
|
||||
XX(417, EXPECTATION_FAILED, Expectation Failed) \
|
||||
XX(421, MISDIRECTED_REQUEST, Misdirected Request) \
|
||||
XX(422, UNPROCESSABLE_ENTITY, Unprocessable Entity) \
|
||||
XX(423, LOCKED, Locked) \
|
||||
XX(424, FAILED_DEPENDENCY, Failed Dependency) \
|
||||
XX(426, UPGRADE_REQUIRED, Upgrade Required) \
|
||||
XX(428, PRECONDITION_REQUIRED, Precondition Required) \
|
||||
XX(429, TOO_MANY_REQUESTS, Too Many Requests) \
|
||||
XX(431, REQUEST_HEADER_FIELDS_TOO_LARGE, Request Header Fields Too Large) \
|
||||
XX(451, UNAVAILABLE_FOR_LEGAL_REASONS, Unavailable For Legal Reasons) \
|
||||
XX(500, INTERNAL_SERVER_ERROR, Internal Server Error) \
|
||||
XX(501, NOT_IMPLEMENTED, Not Implemented) \
|
||||
XX(502, BAD_GATEWAY, Bad Gateway) \
|
||||
XX(503, SERVICE_UNAVAILABLE, Service Unavailable) \
|
||||
XX(504, GATEWAY_TIMEOUT, Gateway Timeout) \
|
||||
XX(505, HTTP_VERSION_NOT_SUPPORTED, HTTP Version Not Supported) \
|
||||
XX(506, VARIANT_ALSO_NEGOTIATES, Variant Also Negotiates) \
|
||||
XX(507, INSUFFICIENT_STORAGE, Insufficient Storage) \
|
||||
XX(508, LOOP_DETECTED, Loop Detected) \
|
||||
XX(510, NOT_EXTENDED, Not Extended) \
|
||||
XX(511, NETWORK_AUTHENTICATION_REQUIRED, Network Authentication Required) \
|
||||
|
||||
enum http_status
|
||||
{
|
||||
#define XX(num, name, string) HTTP_STATUS_##name = num,
|
||||
HTTP_STATUS_MAP(XX)
|
||||
#undef XX
|
||||
};
|
||||
|
||||
|
||||
/* 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
|
||||
@@ -9,39 +9,40 @@
|
||||
import Foundation
|
||||
|
||||
/// Typealias for a closure that handles an incoming HTTP request
|
||||
/// - 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 WebApp = (HTTPRequest, HTTPResponseWriter) -> HTTPBodyProcessing
|
||||
|
||||
/// 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:
|
||||
/// The following is an example of an echo `HTTPRequestHandler` that returns the request it receives as a response:
|
||||
/// ```swift
|
||||
/// class EchoWebApp: WebAppContaining {
|
||||
/// func serve(req: HTTPRequest, res: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
/// res.writeHeader(status: .ok, headers: [:])
|
||||
/// return .processBody { (chunk, stop) in
|
||||
/// switch chunk {
|
||||
/// case .chunk(let data, let finishedProcessing):
|
||||
/// res.writeBody(data) { _ in
|
||||
/// finishedProcessing()
|
||||
/// }
|
||||
/// case .end:
|
||||
/// res.done()
|
||||
/// default:
|
||||
/// stop = true
|
||||
/// res.abort()
|
||||
/// 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()
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
public protocol WebAppContaining: class {
|
||||
/// serve: function called when a new HTTP request is received by the HTTP server.
|
||||
/// - Parameter req: the incoming HTTP request.
|
||||
/// - Parameter res: an writer providing functions to create an HTTP reponse to the request.
|
||||
/// 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.
|
||||
func serve(req: HTTPRequest, res: HTTPResponseWriter ) -> HTTPBodyProcessing
|
||||
/// - See: `HTTPRequestHandler` for more information
|
||||
func handle(request: HTTPRequest, response: HTTPResponseWriter) -> HTTPBodyProcessing
|
||||
}
|
||||
|
||||
/// The result returned as part of a completion handler
|
||||
|
||||
@@ -58,7 +58,7 @@ extension HTTPHeaders : ExpressibleByDictionaryLiteral {
|
||||
extension HTTPHeaders {
|
||||
// Used instead of HTTPHeaders to save CPU on dictionary construction
|
||||
/// :nodoc:
|
||||
public struct Literal : ExpressibleByDictionaryLiteral {
|
||||
public struct Literal: ExpressibleByDictionaryLiteral {
|
||||
let fields: [(name: Name, value: String)]
|
||||
|
||||
public init(dictionaryLiteral: (Name, String)...) {
|
||||
@@ -102,7 +102,7 @@ extension HTTPHeaders : Sequence {
|
||||
}
|
||||
}
|
||||
|
||||
struct StorageIterator : IteratorProtocol {
|
||||
struct StorageIterator: IteratorProtocol {
|
||||
var headers: DictionaryIterator<Name, [String]>
|
||||
var header: (name: Name, values: IndexingIterator<[String]>)?
|
||||
|
||||
@@ -126,9 +126,8 @@ extension HTTPHeaders : Sequence {
|
||||
|
||||
/// HTTPHeaders structure.
|
||||
extension HTTPHeaders {
|
||||
|
||||
/// Type used for the name of a HTTP header in the `HTTPHeaders` storage.
|
||||
public struct Name : Hashable, ExpressibleByStringLiteral, CustomStringConvertible {
|
||||
public struct Name: Hashable, ExpressibleByStringLiteral, CustomStringConvertible {
|
||||
let original: String
|
||||
let lowercased: String
|
||||
public let hashValue: Int
|
||||
@@ -156,7 +155,7 @@ extension HTTPHeaders {
|
||||
public var description: String {
|
||||
return original
|
||||
}
|
||||
|
||||
|
||||
/// :nodoc:
|
||||
public static func == (lhs: Name, rhs: Name) -> Bool {
|
||||
return lhs.lowercased == rhs.lowercased
|
||||
@@ -164,7 +163,7 @@ extension HTTPHeaders {
|
||||
|
||||
// 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.
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
public struct HTTPMethod {
|
||||
/// HTTP method
|
||||
public let method: String
|
||||
|
||||
|
||||
/// Creates an HTTP method
|
||||
public init(_ method: String) {
|
||||
self.method = method.uppercased()
|
||||
@@ -88,16 +88,15 @@ extension HTTPMethod {
|
||||
}
|
||||
|
||||
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
|
||||
@@ -109,12 +108,12 @@ extension HTTPMethod : ExpressibleByStringLiteral {
|
||||
public init(stringLiteral: String) {
|
||||
self.init(stringLiteral)
|
||||
}
|
||||
|
||||
|
||||
/// :nodoc:
|
||||
public init(unicodeScalarLiteral: String) {
|
||||
self.init(unicodeScalarLiteral)
|
||||
}
|
||||
|
||||
|
||||
/// :nodoc:
|
||||
public init(extendedGraphemeClusterLiteral: String) {
|
||||
self.init(extendedGraphemeClusterLiteral)
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Dispatch
|
||||
import Foundation
|
||||
|
||||
/// A structure representing the headers from a HTTP request, without the body of the request.
|
||||
public struct HTTPRequest {
|
||||
@@ -21,9 +21,9 @@ public struct HTTPRequest {
|
||||
public var headers: HTTPHeaders
|
||||
}
|
||||
|
||||
/// Method that takes a chunk of request body and is expected to write to the ResponseWriter
|
||||
/// 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: Bool that can be set to true in order to prevent further processing
|
||||
/// - 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
|
||||
|
||||
@@ -12,7 +12,7 @@ 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
|
||||
public var httpVersion: HTTPVersion
|
||||
/// HTTP response status
|
||||
public var status: HTTPResponseStatus
|
||||
/// HTTP response headers
|
||||
@@ -21,41 +21,40 @@ public struct HTTPResponse {
|
||||
|
||||
/// HTTPResponseWriter provides functions to create an HTTP response
|
||||
public protocol HTTPResponseWriter : class {
|
||||
|
||||
/// writeHeader: Writer function to create the headers for an HTTP response
|
||||
/// 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)
|
||||
|
||||
/// writeTrailer: Writer function to write a trailer header as part of the HTTP response
|
||||
|
||||
/// 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)
|
||||
|
||||
/// writeBody: Writer function to write data to the body of the HTTP response
|
||||
|
||||
/// 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)
|
||||
|
||||
/// done: Writer function to complete the HTTP response
|
||||
|
||||
/// 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 funtion to write the headers for an HTTP response without a completion handler
|
||||
/// 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 funtion to write a HTTP response with no headers or completion handler
|
||||
/// 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: [:])
|
||||
@@ -95,7 +94,7 @@ public struct HTTPResponseStatus: Equatable, CustomStringConvertible, Expressibl
|
||||
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
|
||||
@@ -107,7 +106,7 @@ public struct HTTPResponseStatus: Equatable, CustomStringConvertible, Expressibl
|
||||
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)
|
||||
@@ -226,6 +225,7 @@ public struct HTTPResponseStatus: Equatable, CustomStringConvertible, Expressibl
|
||||
/// 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"
|
||||
@@ -289,7 +289,7 @@ public struct HTTPResponseStatus: Equatable, CustomStringConvertible, Expressibl
|
||||
default: return "http_\(code)"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// :nodoc:
|
||||
public var description: String {
|
||||
return "\(code) \(reasonPhrase)"
|
||||
@@ -349,7 +349,7 @@ public struct HTTPResponseStatus: Equatable, CustomStringConvertible, Expressibl
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public static func ==(lhs: HTTPResponseStatus, rhs: HTTPResponseStatus) -> Bool {
|
||||
public static func == (lhs: HTTPResponseStatus, rhs: HTTPResponseStatus) -> Bool {
|
||||
return lhs.code == rhs.code
|
||||
}
|
||||
}
|
||||
@@ -360,30 +360,30 @@ public protocol UnsafeHTTPResponseBody {
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
extension UnsafeRawBufferPointer : UnsafeHTTPResponseBody {
|
||||
extension UnsafeRawBufferPointer: UnsafeHTTPResponseBody {
|
||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
||||
return try body(self)
|
||||
}
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public protocol HTTPResponseBody : UnsafeHTTPResponseBody {}
|
||||
public protocol HTTPResponseBody: UnsafeHTTPResponseBody {}
|
||||
|
||||
extension Data : HTTPResponseBody {
|
||||
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 {
|
||||
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 {
|
||||
extension String: HTTPResponseBody {
|
||||
/// :nodoc:
|
||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
||||
return try ContiguousArray(utf8).withUnsafeBytes(body)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
/// Definition of an HTTP server.
|
||||
public protocol HTTPServing : class {
|
||||
|
||||
/// Start the HTTP server on the given `port`, using `handler` to process incoming requests
|
||||
func start(port: Int, handler: @escaping HTTPRequestHandler) throws
|
||||
|
||||
/// Stop the server
|
||||
func stop()
|
||||
|
||||
/// The port the server is listening on
|
||||
var port: Int { get }
|
||||
|
||||
/// The number of current connections
|
||||
var connectionCount: Int { get }
|
||||
}
|
||||
|
||||
/// 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: HTTPServing {
|
||||
private let server = PoCSocketSimpleServer()
|
||||
|
||||
/// Create an instance of the server. This needs to be followed with a call to `start(port:handler:)`
|
||||
public init() {
|
||||
}
|
||||
|
||||
/// Start the HTTP server on the given `port` number, using a `HTTPRequestHandler` to process incoming requests.
|
||||
public func start(port: Int = 0, handler: @escaping HTTPRequestHandler) throws {
|
||||
try server.start(port: port, 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
|
||||
}
|
||||
}
|
||||
@@ -6,25 +6,22 @@
|
||||
// See http://swift.org/LICENSE.txt for license information
|
||||
//
|
||||
|
||||
import CHTTPParser
|
||||
import Foundation
|
||||
import Dispatch
|
||||
|
||||
import CHTTPParser
|
||||
|
||||
|
||||
/// Class that wraps the CHTTPParser and calls the `WebApp` to get the response
|
||||
/// Class that wraps the CHTTPParser and calls the `HTTPRequestHandler` to get the response
|
||||
/// :nodoc:
|
||||
public class StreamingParser: HTTPResponseWriter {
|
||||
|
||||
let webapp: WebApp
|
||||
|
||||
let handle: HTTPRequestHandler
|
||||
|
||||
/// Time to leave socket open waiting for next request to start
|
||||
public static let keepAliveTimeout: TimeInterval = 5
|
||||
|
||||
/// Flag to track if the client wants to send multiple requests on the same TCP connection
|
||||
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?
|
||||
@@ -45,12 +42,7 @@ public class StreamingParser: HTTPResponseWriter {
|
||||
}
|
||||
}
|
||||
|
||||
/// Theoretical limit of how many open requests we can have. Used in Keep-Alive Header
|
||||
let maxRequests = 100
|
||||
|
||||
/// Optional 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. If not present, the client will not be limited in number of
|
||||
/// connections that can be made simultaneously
|
||||
/// 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
|
||||
@@ -59,14 +51,34 @@ public class StreamingParser: HTTPResponseWriter {
|
||||
/// 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()
|
||||
@@ -76,85 +88,83 @@ public class StreamingParser: HTTPResponseWriter {
|
||||
|
||||
/// Is the currently parsed request an upgrade request?
|
||||
public private(set) var upgradeRequested = false
|
||||
|
||||
/// Class that wraps the CHTTPParser and calls the `WebApp` to get the response
|
||||
|
||||
/// Class that wraps the CHTTPParser and calls the `HTTPRequestHandler` to get the response
|
||||
///
|
||||
/// - Parameter webapp: function that is used to create the response
|
||||
public init(webapp: @escaping WebApp, connectionCounter: CurrentConnectionCounting? = nil) {
|
||||
self.webapp = webapp
|
||||
/// - 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
|
||||
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
|
||||
|
||||
httpParserSettings.on_message_complete = { parser -> Int32 in
|
||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||
return Int32(0)
|
||||
return 0
|
||||
}
|
||||
return listener.messageCompleted()
|
||||
}
|
||||
|
||||
httpParserSettings.on_headers_complete = {
|
||||
parser -> Int32 in
|
||||
|
||||
httpParserSettings.on_headers_complete = { parser -> Int32 in
|
||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||
return Int32(0)
|
||||
return 0
|
||||
}
|
||||
let methodId = parser?.pointee.method
|
||||
let methodName = String(validatingUTF8:http_method_str(http_method(rawValue: methodId ?? 0))) ?? "GET"
|
||||
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 = get_upgrade_value(parser) == 1
|
||||
|
||||
return listener.headersCompleted(methodName: methodName, majorVersion: major, minorVersion: minor, keepAlive: keepAlive, upgrade: upgradeRequested)
|
||||
//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
|
||||
|
||||
httpParserSettings.on_header_field = { (parser, chunk, length) -> Int32 in
|
||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||
return Int32(0)
|
||||
return 0
|
||||
}
|
||||
return listener.headerFieldReceived(data: chunk, length: length)
|
||||
}
|
||||
|
||||
httpParserSettings.on_header_value = {
|
||||
(parser, chunk, length) -> Int32 in
|
||||
|
||||
httpParserSettings.on_header_value = { (parser, chunk, length) -> Int32 in
|
||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||
return Int32(0)
|
||||
return 0
|
||||
}
|
||||
return listener.headerValueReceived(data: chunk, length: length)
|
||||
}
|
||||
|
||||
httpParserSettings.on_body = {
|
||||
(parser, chunk, length) -> Int32 in
|
||||
|
||||
httpParserSettings.on_body = { (parser, chunk, length) -> Int32 in
|
||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||
return Int32(0)
|
||||
return 0
|
||||
}
|
||||
return listener.bodyReceived(data: chunk, length: length)
|
||||
}
|
||||
|
||||
httpParserSettings.on_url = {
|
||||
(parser, chunk, length) -> Int32 in
|
||||
|
||||
httpParserSettings.on_url = { (parser, chunk, length) -> Int32 in
|
||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||
return Int32(0)
|
||||
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
|
||||
@@ -164,18 +174,18 @@ public class StreamingParser: HTTPResponseWriter {
|
||||
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 {
|
||||
func processCurrentCallback(_ currentCallBack: CallbackRecord) -> Bool {
|
||||
if lastCallBack == currentCallBack {
|
||||
return false
|
||||
}
|
||||
@@ -183,30 +193,32 @@ public class StreamingParser: HTTPResponseWriter {
|
||||
case .headerFieldReceived:
|
||||
if let parserBuffer = self.parserBuffer {
|
||||
self.lastHeaderName = String(data: parserBuffer, encoding: .utf8)
|
||||
self.parserBuffer=nil
|
||||
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) {
|
||||
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
|
||||
self.parserBuffer = nil
|
||||
} else {
|
||||
print("Missing parserBuffer after \(lastCallBack)")
|
||||
}
|
||||
case .headersCompleted:
|
||||
self.parserBuffer=nil
|
||||
|
||||
self.parserBuffer = nil
|
||||
|
||||
if !upgradeRequested {
|
||||
self.httpBodyProcessingCallback = self.webapp(self.createRequest(), self)
|
||||
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
|
||||
self.parserBuffer = nil
|
||||
} else {
|
||||
print("Missing parserBuffer after \(lastCallBack)")
|
||||
}
|
||||
@@ -222,109 +234,136 @@ public class StreamingParser: HTTPResponseWriter {
|
||||
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 stop=false
|
||||
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, &stop)
|
||||
handler(.end, &dummy)
|
||||
case .discardBody:
|
||||
done()
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func headersCompleted(methodName:String, majorVersion: Int, minorVersion:Int, keepAlive: Bool, upgrade:Bool) -> Int32 {
|
||||
|
||||
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: StreamingParser.keepAliveTimeout).timeIntervalSinceReferenceDate
|
||||
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 }
|
||||
data.withMemoryRebound(to: UInt8.self, capacity: length) { (ptr) -> Void in
|
||||
self.parserBuffer == nil ? self.parserBuffer = Data(bytes:data, count:length) : self.parserBuffer?.append(ptr, count:length)
|
||||
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 }
|
||||
data.withMemoryRebound(to: UInt8.self, capacity: length) { (ptr) -> Void in
|
||||
self.parserBuffer == nil ? self.parserBuffer = Data(bytes:data, count:length) : self.parserBuffer?.append(ptr, count:length)
|
||||
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
|
||||
let buff = UnsafeBufferPointer<UInt8>(start: ptr, count: length)
|
||||
let chunk = DispatchData(bytes:buff)
|
||||
#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 {
|
||||
var stop=false
|
||||
var finished=false
|
||||
while !stop && !finished {
|
||||
switch chunkHandler {
|
||||
switch chunkHandler {
|
||||
case .processBody(let handler):
|
||||
handler(.chunk(data: chunk, finishedProcessing: {
|
||||
finished=true
|
||||
}), &stop)
|
||||
//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:
|
||||
finished=true
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
func urlReceived(data: UnsafePointer<Int8>?, length: Int) -> Int32 {
|
||||
processCurrentCallback(.urlReceived)
|
||||
guard let data = data else { return 0 }
|
||||
data.withMemoryRebound(to: UInt8.self, capacity: length) { (ptr) -> Void in
|
||||
self.parserBuffer == nil ? self.parserBuffer = Data(bytes:data, count:length) : self.parserBuffer?.append(ptr, count:length)
|
||||
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)
|
||||
return HTTPRequest(method: parsedHTTPMethod!,
|
||||
target: parsedURL!,
|
||||
httpVersion: parsedHTTPVersion!,
|
||||
headers: parsedHeaders)
|
||||
}
|
||||
|
||||
|
||||
public func writeHeader(status: HTTPResponseStatus, headers: HTTPHeaders, completion: @escaping (Result) -> Void) {
|
||||
// TODO call completion()
|
||||
|
||||
guard !headersWritten else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
var header = "HTTP/1.1 \(status.code) \(status.reasonPhrase)\r\n"
|
||||
|
||||
let isContinue = status == .continue
|
||||
@@ -333,17 +372,17 @@ public class StreamingParser: HTTPResponseWriter {
|
||||
if !isContinue {
|
||||
adjustHeaders(status: status, headers: &headers)
|
||||
}
|
||||
|
||||
|
||||
for (key, value) in headers {
|
||||
// TODO encode value using [RFC5987]
|
||||
header += "\(key): \(value)\r\n"
|
||||
}
|
||||
header.append("\r\n")
|
||||
|
||||
|
||||
// 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)
|
||||
self.parserConnector?.queueSocketWrite(data, completion: completion)
|
||||
if !isContinue {
|
||||
headersWritten = true
|
||||
}
|
||||
@@ -375,31 +414,29 @@ public class StreamingParser: HTTPResponseWriter {
|
||||
headers[.transferEncoding] = nil
|
||||
}
|
||||
|
||||
let availableConnections = maxRequests - (self.connectionCounter?.connectionCount ?? 0)
|
||||
|
||||
if clientRequestedKeepAlive && (availableConnections > 0) {
|
||||
if clientRequestedKeepAlive {
|
||||
headers[.connection] = "Keep-Alive"
|
||||
headers[.keepAlive] = "timeout=\(Int(StreamingParser.keepAliveTimeout)), max=\(availableConnections)"
|
||||
} 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 {
|
||||
@@ -410,25 +447,23 @@ public class StreamingParser: HTTPResponseWriter {
|
||||
dataToWrite.append(chunkEnd)
|
||||
return dataToWrite
|
||||
}
|
||||
} else if let d = data as? Data {
|
||||
dataToWrite = d
|
||||
} else if let data = data as? Data {
|
||||
dataToWrite = data
|
||||
} else {
|
||||
dataToWrite = data.withUnsafeBytes { Data($0) }
|
||||
}
|
||||
|
||||
self.parserConnector?.queueSocketWrite(dataToWrite)
|
||||
|
||||
completion(.ok)
|
||||
|
||||
self.parserConnector?.queueSocketWrite(dataToWrite, completion: completion)
|
||||
}
|
||||
|
||||
|
||||
public func done(completion: @escaping (Result) -> Void) {
|
||||
if isChunked {
|
||||
let chunkTerminate = "0\r\n\r\n".data(using: .utf8)!
|
||||
self.parserConnector?.queueSocketWrite(chunkTerminate)
|
||||
self.parserConnector?.queueSocketWrite(chunkTerminate, completion: completion)
|
||||
}
|
||||
|
||||
|
||||
self.parsedHTTPMethod = nil
|
||||
self.parsedURL=nil
|
||||
self.parsedURL = nil
|
||||
self.parsedHeaders = HTTPHeaders()
|
||||
self.lastHeaderName = nil
|
||||
self.parserBuffer = nil
|
||||
@@ -438,27 +473,23 @@ public class StreamingParser: HTTPResponseWriter {
|
||||
self.headersWritten = false
|
||||
self.httpBodyProcessingCallback = nil
|
||||
self.upgradeRequested = false
|
||||
|
||||
let closeAfter = {
|
||||
if self.clientRequestedKeepAlive {
|
||||
self.keepAliveUntil = Date(timeIntervalSinceNow:StreamingParser.keepAliveTimeout).timeIntervalSinceReferenceDate
|
||||
self.parserConnector?.responseComplete()
|
||||
} else {
|
||||
self.parserConnector?.closeWriter()
|
||||
}
|
||||
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
|
||||
self.parserConnector?.responseComplete()
|
||||
} else {
|
||||
self.parserConnector?.responseCompleteCloseWriter()
|
||||
}
|
||||
|
||||
// FIXME I do not understand what code written here before was meant to do
|
||||
// If it was about delayed closure invocation then it couldn't work either
|
||||
// Here is the equivalent code
|
||||
closeAfter()
|
||||
completion(.ok)
|
||||
}
|
||||
|
||||
public func abort() {
|
||||
fatalError("abort called, not sure what to do with it")
|
||||
}
|
||||
|
||||
|
||||
deinit {
|
||||
httpParser.data = nil
|
||||
}
|
||||
@@ -468,18 +499,20 @@ public class StreamingParser: HTTPResponseWriter {
|
||||
/// 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) -> Void
|
||||
|
||||
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() -> Void
|
||||
|
||||
func responseBeginning()
|
||||
|
||||
/// Let the network know that a response is complete, so it can be closed after timeout
|
||||
func responseComplete() -> Void
|
||||
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() -> Void
|
||||
func closeWriter()
|
||||
}
|
||||
|
||||
/// Delegate that can tell us how many connections are in-flight so we can set the Keep-Alive header
|
||||
|
||||
@@ -30,7 +30,7 @@ extension HTTPVersion : Hashable {
|
||||
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
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
// 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
|
||||
|
||||
///: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 {
|
||||
|
||||
/// 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)`
|
||||
internal private(set) var isListening = false
|
||||
|
||||
/// Track state between `accept(2)/bind(2)` and `close(2)`
|
||||
internal private(set) var isConnected = false
|
||||
|
||||
/// 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
|
||||
}
|
||||
}
|
||||
|
||||
/// 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 = 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 = 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 socketfd < 1 {
|
||||
//Nothing to do. Maybe it was closed already
|
||||
return
|
||||
}
|
||||
//print("Shutting down socket \(self.socketfd)")
|
||||
if self.isListening || self.isConnected {
|
||||
//print("Shutting down socket")
|
||||
_ = shutdown(self.socketfd, Int32(SHUT_RDWR))
|
||||
self.isListening = false
|
||||
}
|
||||
self.isConnected = false
|
||||
close(self.socketfd)
|
||||
}
|
||||
|
||||
/// 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
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
let _ = withUnsafePointer(to: &addr) {
|
||||
bind(self.socketfd, UnsafePointer<sockaddr>(OpaquePointer($0)), socklen_t(MemoryLayout<sockaddr_in>.size))
|
||||
}
|
||||
|
||||
//print("bindResult is \(bindResult)")
|
||||
|
||||
let _ = listen(self.socketfd, maxBacklogSize)
|
||||
|
||||
isListening = true
|
||||
|
||||
//print("listenResult is \(listenResult)")
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
//print("listeningPort is \(listeningPort)")
|
||||
}
|
||||
|
||||
/// 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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
// 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
|
||||
|
||||
///: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
|
||||
var shouldShutdown: Bool = false
|
||||
|
||||
/// 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
|
||||
}
|
||||
}
|
||||
|
||||
///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 {
|
||||
guard let socket = self.socket else {
|
||||
return false
|
||||
}
|
||||
return socket.isOpen()
|
||||
}
|
||||
|
||||
/// 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() {
|
||||
let now = Date().timeIntervalSinceReferenceDate
|
||||
if let keepAliveUntil = parser?.keepAliveUntil, now >= keepAliveUntil {
|
||||
print("Closing idle socket \(socketFD)")
|
||||
close()
|
||||
}
|
||||
}
|
||||
|
||||
func cleanup() {
|
||||
self.readerSource?.setEventHandler(handler: nil)
|
||||
self.readerSource?.setCancelHandler(handler: nil)
|
||||
|
||||
self.readerSource = nil
|
||||
self.socket = nil
|
||||
self.parser?.parserConnector = nil //allows for memory to be reclaimed
|
||||
self.parser = nil
|
||||
}
|
||||
|
||||
/// Called by the parser to let us know that a response has started being created
|
||||
public func responseBeginning() {
|
||||
self.socketWriterQueue.async { [weak self] in
|
||||
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.socketWriterQueue.async { [weak self] in
|
||||
self?.responseCompleted = true
|
||||
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.socketWriterQueue.async { [weak self] in
|
||||
self?.responseCompleted = true
|
||||
self?.close()
|
||||
}
|
||||
}
|
||||
|
||||
/// Starts reading from the socket and feeding that data to the parser
|
||||
public func process() {
|
||||
try! socket?.setBlocking(mode: true)
|
||||
|
||||
let tempReaderSource = DispatchSource.makeReadSource(fileDescriptor: socket?.socketfd ?? -1,
|
||||
queue: socketReaderQueue)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
var length = 1 //initial value
|
||||
|
||||
do {
|
||||
if strongSelf.socket?.socketfd ?? -1 > 0 {
|
||||
var maxLength: Int = Int(strongSelf.readerSource?.data ?? 0)
|
||||
if (maxLength > strongSelf.maxReadLength) || (maxLength <= 0) {
|
||||
maxLength = strongSelf.maxReadLength
|
||||
}
|
||||
var readBuffer: UnsafeMutablePointer<Int8> = UnsafeMutablePointer<Int8>.allocate(capacity: maxLength)
|
||||
length = try strongSelf.socket?.socketRead(into: &readBuffer, maxLength:maxLength) ?? -1
|
||||
if length > 0 {
|
||||
self?.responseCompleted = false
|
||||
|
||||
let data = Data(bytes: readBuffer, count: length)
|
||||
let numberParsed = strongSelf.parser?.readStream(data:data) ?? 0
|
||||
|
||||
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)")
|
||||
self?.readerSource?.cancel()
|
||||
self?.errorOccurred = true
|
||||
self?.close()
|
||||
}
|
||||
if length == 0 {
|
||||
self?.readerSource?.cancel()
|
||||
}
|
||||
if length < 0 {
|
||||
self?.errorOccurred = true
|
||||
self?.readerSource?.cancel()
|
||||
self?.close()
|
||||
}
|
||||
}
|
||||
|
||||
tempReaderSource.setCancelHandler { [weak self] in
|
||||
self?.close() //close if we can
|
||||
}
|
||||
|
||||
self.readerSource = tempReaderSource
|
||||
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
|
||||
let result = try socket?.socketWrite(from: ptr + offset, bufSize:
|
||||
data.count - offset) ?? -1
|
||||
if result < 0 {
|
||||
print("Received broken write socket indication")
|
||||
errorOccurred = true
|
||||
} else {
|
||||
written += result
|
||||
}
|
||||
}
|
||||
offset = data.count - written
|
||||
}
|
||||
if errorOccurred {
|
||||
close()
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
print("Received write socket error: \(error)")
|
||||
errorOccurred = true
|
||||
close()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,101 +8,117 @@
|
||||
|
||||
import Dispatch
|
||||
import Foundation
|
||||
import HTTP
|
||||
|
||||
import Socket
|
||||
|
||||
//import HeliumLogger
|
||||
|
||||
#if os(Linux)
|
||||
import Signals
|
||||
#endif
|
||||
|
||||
|
||||
// MARK: Server
|
||||
|
||||
/// An HTTP server that listens for connections on a TCP socket and spawns Listeners to handle them.
|
||||
public class BlueSocketSimpleServer : CurrentConnectionCounting {
|
||||
|
||||
|
||||
/// Socket to listen on for connections
|
||||
private let serverSocket: Socket
|
||||
///: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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
public init() {
|
||||
#if os(Linux)
|
||||
Signals.trap(signal: .pipe) {
|
||||
_ in
|
||||
print("Receiver closed socket, SIGPIPE ignored")
|
||||
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()
|
||||
}
|
||||
#endif
|
||||
|
||||
serverSocket = try! Socket.create()
|
||||
pruneSocketTimer = DispatchSource.makeTimerSource(queue: DispatchQueue(label: "pruneSocketTimer"))
|
||||
queueMax = 4 //sensible default
|
||||
acceptMax = 8 //sensible default
|
||||
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)
|
||||
/// - webapp: Function that creates the HTTP Response from the HTTP Request
|
||||
/// - 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, webapp: @escaping WebApp) throws {
|
||||
public func start(port: Int = 0,
|
||||
queueCount: Int = 0,
|
||||
acceptCount: Int = 0,
|
||||
maxReadLength: Int = 1048576,
|
||||
keepAliveTimeout: Double = 5.0,
|
||||
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
|
||||
}
|
||||
try self.serverSocket.listen(on: port, maxBacklogSize: 100)
|
||||
|
||||
try self.serverSocket.bindAndListen(on: port)
|
||||
|
||||
pruneSocketTimer.setEventHandler { [weak self] in
|
||||
self?.connectionListenerList.prune()
|
||||
}
|
||||
pruneSocketTimer.scheduleRepeating(deadline: .now() + StreamingParser.keepAliveTimeout, interval: .seconds(Int(StreamingParser.keepAliveTimeout)))
|
||||
#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 i in 0..<queueMax {
|
||||
readQueues.append(DispatchQueue(label: "Read Queue \(i)"))
|
||||
writeQueues.append(DispatchQueue(label: "Write Queue \(i)"))
|
||||
|
||||
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")
|
||||
|
||||
|
||||
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 clientSocket = try self.serverSocket.acceptClientConnection()
|
||||
let streamingParser = StreamingParser(webapp: webapp, connectionCounter: self)
|
||||
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 = BlueSocketConnectionListener(socket:clientSocket, parser: streamingParser, readQueue:readQueue, writeQueue: writeQueue)
|
||||
let listener = PoCSocketConnectionListener(socket: clientSocket, parser: streamingParser, readQueue:readQueue, writeQueue: writeQueue, maxReadLength: maxReadLength)
|
||||
listenerCount += 1
|
||||
acceptSemaphore.wait()
|
||||
acceptQueue.async { [weak listener] in
|
||||
@@ -110,77 +126,71 @@ public class BlueSocketSimpleServer : CurrentConnectionCounting {
|
||||
acceptSemaphore.signal()
|
||||
}
|
||||
self.connectionListenerList.add(listener)
|
||||
|
||||
} catch let error {
|
||||
print("Error accepting client connection: \(error)")
|
||||
}
|
||||
} while self.serverSocket.isListening
|
||||
} while !self.isShuttingDown && self.serverSocket.isListening
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Stop the server and close the sockets
|
||||
public func stop() {
|
||||
isShuttingDown = true
|
||||
connectionListenerList.closeAll()
|
||||
serverSocket.close()
|
||||
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?
|
||||
weak var value: T?
|
||||
init (_ value: T) {
|
||||
self.value = value
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let lock = DispatchSemaphore(value: 1)
|
||||
|
||||
|
||||
/// Storage for weak connection listeners
|
||||
var storage = [WeakConnectionListener<BlueSocketConnectionListener>]()
|
||||
|
||||
|
||||
var storage = [WeakConnectionListener<PoCSocketConnectionListener>]()
|
||||
|
||||
/// Add a new connection to the collection
|
||||
///
|
||||
/// - Parameter listener: socket manager object
|
||||
func add(_ listener:BlueSocketConnectionListener) {
|
||||
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 { nil != $0.value }.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 { nil != $0.value }.filter { $0.value?.isOpen ?? false}
|
||||
storage = storage.filter { nil != $0.value }.filter { $0.value?.isOpen ?? false }
|
||||
lock.signal()
|
||||
}
|
||||
|
||||
|
||||
/// Count of collections
|
||||
var count: Int {
|
||||
lock.wait()
|
||||
let c = storage.filter { nil != $0.value }.count
|
||||
let count = storage.filter { nil != $0.value }.count
|
||||
lock.signal()
|
||||
return c
|
||||
return count
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,42 +43,42 @@ class HeadersTests: XCTestCase {
|
||||
])
|
||||
|
||||
headers = HTTPHeaders()
|
||||
let initialCount = headers.makeIterator().reduce(0) { (last, element) -> Int in return last + 1 }
|
||||
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, element) -> Int in return last + 1 }
|
||||
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")
|
||||
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")
|
||||
XCTAssertEqual(2, testHeaderValueArray2.count)
|
||||
XCTAssertEqual("Test Value", testHeaderValueArray2.first ?? "Not Found")
|
||||
let testHeaderValueArray2Remainder = testHeaderValueArray2.dropFirst()
|
||||
XCTAssertEqual("Test Value 2",testHeaderValueArray2Remainder.first ?? "Not Found")
|
||||
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)
|
||||
XCTAssertEqual(1, testHeaderValueArray3.count)
|
||||
|
||||
//Overwrite
|
||||
headers[valuesFor: "TEST-HEADER"]=["Test Value 4a","Test Value 4b"]
|
||||
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")
|
||||
XCTAssertEqual(2, testHeaderValueArray4.count)
|
||||
XCTAssertEqual("Test Value 4a", testHeaderValueArray4.first ?? "Not Found")
|
||||
let testHeaderValueArray4Remainder = testHeaderValueArray4.dropFirst()
|
||||
XCTAssertEqual("Test Value 4b",testHeaderValueArray4Remainder.first ?? "Not Found")
|
||||
XCTAssertEqual("Test Value 4b", testHeaderValueArray4Remainder.first ?? "Not Found")
|
||||
}
|
||||
|
||||
|
||||
static var allTests = [
|
||||
("testHeaders", testHeaders),
|
||||
]
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,23 +9,22 @@
|
||||
import Foundation
|
||||
import HTTP
|
||||
|
||||
|
||||
/// Simple `WebApp` that just echoes back whatever input it gets
|
||||
class EchoWebApp: WebAppContaining {
|
||||
func serve(req: HTTPRequest, res: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
/// 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
|
||||
res.writeHeader(status: .ok, headers: ["Transfer-Encoding": "chunked", "X-foo": "bar"])
|
||||
response.writeHeader(status: .ok, headers: ["Transfer-Encoding": "chunked", "X-foo": "bar"])
|
||||
return .processBody { (chunk, stop) in
|
||||
switch chunk {
|
||||
case .chunk(let data, let finishedProcessing):
|
||||
res.writeBody(data) { _ in
|
||||
response.writeBody(data) { _ in
|
||||
finishedProcessing()
|
||||
}
|
||||
case .end:
|
||||
res.done()
|
||||
response.done()
|
||||
default:
|
||||
stop = true /* don't call us anymore */
|
||||
res.abort()
|
||||
response.abort()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,21 +9,21 @@
|
||||
import Foundation
|
||||
import HTTP
|
||||
|
||||
/// Simple `WebApp` that prints "Hello, World" as per K&R
|
||||
class HelloWorldWebApp: WebAppContaining {
|
||||
func serve(req: HTTPRequest, res: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
/// 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
|
||||
res.writeHeader(status: .ok, headers: [.transferEncoding: "chunked", "X-foo": "bar"])
|
||||
response.writeHeader(status: .ok, headers: [.transferEncoding: "chunked", "X-foo": "bar"])
|
||||
return .processBody { (chunk, stop) in
|
||||
switch chunk {
|
||||
case .chunk(_, let finishedProcessing):
|
||||
finishedProcessing()
|
||||
case .end:
|
||||
res.writeBody("Hello, World!")
|
||||
res.done()
|
||||
response.writeBody("Hello, World!")
|
||||
response.done()
|
||||
default:
|
||||
stop = true /* don't call us anymore */
|
||||
res.abort()
|
||||
response.abort()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,11 @@
|
||||
import Foundation
|
||||
import HTTP
|
||||
|
||||
/// `HelloWorldWebApp` that sets the keep alive header for XCTest purposes
|
||||
class HelloWorldKeepAliveWebApp: WebAppContaining {
|
||||
func serve(req: HTTPRequest, res: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
/// `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
|
||||
res.writeHeader(status: .ok, headers: [
|
||||
response.writeHeader(status: .ok, headers: [
|
||||
"Transfer-Encoding": "chunked",
|
||||
"Connection": "Keep-Alive",
|
||||
"Keep-Alive": "timeout=5, max=10",
|
||||
@@ -23,11 +23,11 @@ class HelloWorldKeepAliveWebApp: WebAppContaining {
|
||||
case .chunk(_, let finishedProcessing):
|
||||
finishedProcessing()
|
||||
case .end:
|
||||
res.writeBody("Hello, World!")
|
||||
res.done()
|
||||
response.writeBody("Hello, World!")
|
||||
response.done()
|
||||
default:
|
||||
stop = true /* don't call us anymore */
|
||||
res.abort()
|
||||
response.abort()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,11 @@
|
||||
import Foundation
|
||||
import HTTP
|
||||
|
||||
/// Simple `WebApp` that returns 200: OK without a body
|
||||
class OkWebApp: WebAppContaining {
|
||||
func serve(req: HTTPRequest, res: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
/// 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
|
||||
res.writeHeader(status: .ok, headers: ["Transfer-Encoding": "chunked", "X-foo": "bar"])
|
||||
response.writeHeader(status: .ok, headers: ["Transfer-Encoding": "chunked", "X-foo": "bar"])
|
||||
return .discardBody
|
||||
}
|
||||
}
|
||||
@@ -7,52 +7,50 @@
|
||||
//
|
||||
|
||||
/*
|
||||
|
||||
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 `WebApp`s to use when writing tests.
|
||||
|
||||
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 `WebApp`. Normally used during XCTests
|
||||
public class SimpleResponseCreator: WebAppContaining {
|
||||
/// 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 serve(req: HTTPRequest, res: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||
|
||||
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) {
|
||||
if data.count > 0 {
|
||||
self.buffer.append(Data(data))
|
||||
}
|
||||
finishedProcessing()
|
||||
case .end:
|
||||
let response = self.completionHandler(req, self.buffer)
|
||||
var headers = response.headers
|
||||
let responseResult = self.completionHandler(request, self.buffer)
|
||||
var headers = responseResult.headers
|
||||
headers.replace([.transferEncoding: "chunked"])
|
||||
res.writeHeader(status: response.status, headers: headers)
|
||||
res.writeBody(response.body) { _ in
|
||||
res.done()
|
||||
response.writeHeader(status: responseResult.status, headers: headers)
|
||||
response.writeBody(responseResult.body) { _ in
|
||||
response.done()
|
||||
}
|
||||
default:
|
||||
stop = true /* don't call us anymore */
|
||||
res.abort()
|
||||
response.abort()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,44 +14,66 @@ import HTTP
|
||||
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
|
||||
DispatchData(bytes: UnsafeBufferPointer<UInt8>(start: ptr, count: requestBody.count))
|
||||
#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:WebApp) {
|
||||
|
||||
func resolveHandler(_ handler: HTTPRequestHandler) {
|
||||
let chunkHandler = handler(request, self)
|
||||
var stop=false
|
||||
var finished=false
|
||||
while !stop && !finished {
|
||||
switch chunkHandler {
|
||||
if shouldStopProcessingBody {
|
||||
return
|
||||
}
|
||||
switch chunkHandler {
|
||||
case .processBody(let handler):
|
||||
handler(.chunk(data: self.requestBody, finishedProcessing: {
|
||||
finished=true
|
||||
}), &stop)
|
||||
handler(.end, &stop)
|
||||
_shouldStopProcessingBodyLock.wait()
|
||||
handler(.chunk(data: self.requestBody, finishedProcessing: {self._shouldStopProcessingBodyLock.signal()}), &_shouldStopProcessingBody)
|
||||
var dummy = false
|
||||
handler(.end, &dummy)
|
||||
case .discardBody:
|
||||
finished=true
|
||||
}
|
||||
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
|
||||
@@ -60,17 +82,16 @@ class TestResponseResolver: HTTPResponseWriter {
|
||||
}
|
||||
completion(.ok)
|
||||
}
|
||||
|
||||
|
||||
func done(completion: @escaping (Result) -> Void) {
|
||||
completion(.ok)
|
||||
}
|
||||
func done() /* convenience */ {
|
||||
done() { _ in
|
||||
done { _ in
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func abort() {
|
||||
fatalError("abort called, not sure what to do with it")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// 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
|
||||
}
|
||||
}
|
||||
@@ -14,13 +14,13 @@ class ResponseTests: XCTestCase {
|
||||
|
||||
func testOkay() {
|
||||
let okay = HTTPResponseStatus.ok
|
||||
XCTAssertEqual(200,okay.code)
|
||||
XCTAssertEqual("OK",okay.reasonPhrase)
|
||||
XCTAssertEqual(200, okay.code)
|
||||
XCTAssertEqual("OK", okay.reasonPhrase)
|
||||
XCTAssertEqual("\(okay)", "200 OK")
|
||||
}
|
||||
|
||||
func testContinue() {
|
||||
XCTAssertEqual("Continue",HTTPResponseStatus.continue.reasonPhrase)
|
||||
XCTAssertEqual("Continue", HTTPResponseStatus.continue.reasonPhrase)
|
||||
}
|
||||
|
||||
func testNotFound() {
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import Dispatch
|
||||
|
||||
@testable import HTTP
|
||||
@testable import BlueSocketHTTP
|
||||
|
||||
class ServerTests: XCTestCase {
|
||||
func testResponseOK() {
|
||||
let request = HTTPRequest(method: .get, target:"/echo", httpVersion: HTTPVersion(major: 1, minor: 1), headers: ["X-foo": "bar"])
|
||||
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(EchoWebApp().serve)
|
||||
resolver.resolveHandler(EchoHandler().handle)
|
||||
XCTAssertNotNil(resolver.response)
|
||||
XCTAssertNotNil(resolver.responseBody)
|
||||
XCTAssertEqual(HTTPResponseStatus.ok.code, resolver.response?.status.code ?? 0)
|
||||
@@ -23,49 +23,48 @@ class ServerTests: XCTestCase {
|
||||
|
||||
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 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(EchoWebApp().serve)
|
||||
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 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(HelloWorldWebApp().serve)
|
||||
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 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 { (request, body) -> SimpleResponseCreator.Response in
|
||||
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.serve)
|
||||
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")
|
||||
}
|
||||
|
||||
|
||||
func testOkEndToEnd() {
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
|
||||
let server = BlueSocketSimpleServer()
|
||||
|
||||
let server = HTTPServer()
|
||||
do {
|
||||
try server.start(port: 0, webapp: OkWebApp().serve)
|
||||
try server.start(port: 0, handler: OkHandler().handle)
|
||||
let session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
let url = URL(string: "http://localhost:\(server.port)/")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
@@ -91,10 +90,10 @@ class ServerTests: XCTestCase {
|
||||
|
||||
func testHelloEndToEnd() {
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
|
||||
let server = BlueSocketSimpleServer()
|
||||
|
||||
let server = HTTPServer()
|
||||
do {
|
||||
try server.start(port: 0, webapp: HelloWorldWebApp().serve)
|
||||
try server.start(port: 0, handler: HelloWorldHandler().handle)
|
||||
let session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
let url = URL(string: "http://localhost:\(server.port)/helloworld")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
@@ -118,25 +117,24 @@ class ServerTests: XCTestCase {
|
||||
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 { (request, body) -> SimpleResponseCreator.Response in
|
||||
let simpleHelloWebApp = SimpleResponseCreator { (_, body) -> SimpleResponseCreator.Response in
|
||||
return SimpleResponseCreator.Response(
|
||||
status: .ok,
|
||||
headers: ["X-foo": "bar"],
|
||||
body: "Hello, World!".data(using: .utf8)!
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
let server = BlueSocketSimpleServer()
|
||||
let server = HTTPServer()
|
||||
do {
|
||||
try server.start(port: 0, webapp: simpleHelloWebApp.serve)
|
||||
try server.start(port: 0, handler: simpleHelloWebApp.handle)
|
||||
} catch {
|
||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||
}
|
||||
|
||||
|
||||
let session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
let url = URL(string: "http://localhost:\(server.port)/helloworld")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
@@ -162,14 +160,13 @@ class ServerTests: XCTestCase {
|
||||
print("\(#function) stopping server")
|
||||
}
|
||||
|
||||
|
||||
func testRequestEchoEndToEnd() {
|
||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||
let testString="This is a test"
|
||||
|
||||
let server = BlueSocketSimpleServer()
|
||||
let server = HTTPServer()
|
||||
do {
|
||||
try server.start(port: 0, webapp: EchoWebApp().serve)
|
||||
try server.start(port: 0, handler: EchoHandler().handle)
|
||||
let session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
let url = URL(string: "http://localhost:\(server.port)/echo")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
@@ -177,7 +174,7 @@ class ServerTests: XCTestCase {
|
||||
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)")
|
||||
@@ -198,7 +195,7 @@ class ServerTests: XCTestCase {
|
||||
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)")
|
||||
@@ -206,10 +203,10 @@ class ServerTests: XCTestCase {
|
||||
let testString1="This is a test"
|
||||
let testString2="This is a test, too"
|
||||
let testString3="This is also a test"
|
||||
|
||||
let server = BlueSocketSimpleServer()
|
||||
|
||||
let server = HTTPServer()
|
||||
do {
|
||||
try server.start(port: 0, webapp: EchoWebApp().serve)
|
||||
try server.start(port: 0, handler: EchoHandler().handle)
|
||||
let session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
let url = URL(string: "http://localhost:\(server.port)/echo")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
@@ -217,17 +214,15 @@ class ServerTests: XCTestCase {
|
||||
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 headers = response?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
let keepAliveHeader = headers["Keep-Alive"]
|
||||
XCTAssertEqual(connectionHeader,"Keep-Alive","No Keep-Alive Connection")
|
||||
XCTAssertNotNil(keepAliveHeader)
|
||||
XCTAssertNotNil(responseBody,"No Keep-Alive Header")
|
||||
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")
|
||||
@@ -239,11 +234,9 @@ class ServerTests: XCTestCase {
|
||||
let response2 = rawResponse2 as? HTTPURLResponse
|
||||
XCTAssertNil(error2, "\(error2!.localizedDescription)")
|
||||
XCTAssertNotNil(response2)
|
||||
let headers = response2?.allHeaderFields ?? ["":""]
|
||||
let headers = response2?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
let keepAliveHeader = headers["Keep-Alive"]
|
||||
XCTAssertEqual(connectionHeader,"Keep-Alive","No Keep-Alive Connection")
|
||||
XCTAssertNotNil(keepAliveHeader,"No Keep-Alive Header")
|
||||
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||
XCTAssertEqual(server.connectionCount, 1)
|
||||
XCTAssertNotNil(responseBody2)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response2?.statusCode ?? 0)
|
||||
@@ -256,11 +249,9 @@ class ServerTests: XCTestCase {
|
||||
let response = rawResponse as? HTTPURLResponse
|
||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||
XCTAssertNotNil(response)
|
||||
let headers = response?.allHeaderFields ?? ["":""]
|
||||
let headers = response?.allHeaderFields ?? ["": ""]
|
||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||
let keepAliveHeader = headers["Keep-Alive"]
|
||||
XCTAssertEqual(connectionHeader,"Keep-Alive","No Keep-Alive Connection")
|
||||
XCTAssertNotNil(keepAliveHeader,"No Keep-Alive Header")
|
||||
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||
XCTAssertEqual(server.connectionCount, 1)
|
||||
XCTAssertNotNil(responseBody)
|
||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||
@@ -285,29 +276,129 @@ class ServerTests: XCTestCase {
|
||||
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 server = HTTPServer()
|
||||
do {
|
||||
try server.start(port: 0, handler: EchoHandler().handle)
|
||||
let session = URLSession(configuration: URLSessionConfiguration.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)")
|
||||
//Get a file we know exists
|
||||
//let currentDirectoryURL = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
|
||||
let executableUrl = URL(fileURLWithPath: CommandLine.arguments[0])
|
||||
|
||||
let testExecutableData = try! Data(contentsOf: executableUrl)
|
||||
|
||||
|
||||
//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) {
|
||||
if remove > 0 {
|
||||
testDataLong.removeLast(remove)
|
||||
}
|
||||
|
||||
|
||||
let testData = Data(testDataLong)
|
||||
|
||||
let server = BlueSocketSimpleServer()
|
||||
|
||||
let server = PoCSocketSimpleServer()
|
||||
do {
|
||||
try server.start(port: 0, webapp: EchoWebApp().serve)
|
||||
try server.start(port: 0, maxReadLength: chunkSize, handler: EchoHandler().handle)
|
||||
let session = URLSession(configuration: URLSessionConfiguration.default)
|
||||
let url = URL(string: "http://localhost:\(server.port)/echo")!
|
||||
print("Test \(#function) on port \(server.port)")
|
||||
@@ -335,6 +426,103 @@ class ServerTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
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: URLSessionConfiguration.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: URLSessionConfiguration.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) { (responseBody, rawResponse, 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 = [
|
||||
("testEcho", testEcho),
|
||||
("testHello", testHello),
|
||||
@@ -346,5 +534,7 @@ class ServerTests: XCTestCase {
|
||||
("testRequestEchoEndToEnd", testRequestEchoEndToEnd),
|
||||
("testRequestKeepAliveEchoEndToEnd", testRequestKeepAliveEchoEndToEnd),
|
||||
("testRequestLargeEchoEndToEnd", testRequestLargeEchoEndToEnd),
|
||||
("testExplicitCloseConnections", testExplicitCloseConnections),
|
||||
("testRequestLargePostHelloWorld", testRequestLargePostHelloWorld),
|
||||
]
|
||||
}
|
||||
@@ -11,27 +11,26 @@ 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)
|
||||
@@ -39,14 +38,13 @@ class VersionTests: XCTestCase {
|
||||
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)
|
||||
@@ -54,16 +52,16 @@ class VersionTests: XCTestCase {
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
static var allTests = [
|
||||
("testEquals", testEquals),
|
||||
("testGreater", testGreater),
|
||||
|
||||
@@ -8,14 +8,11 @@
|
||||
|
||||
import XCTest
|
||||
@testable import HTTPTests
|
||||
@testable import BlueSocketHTTPTests
|
||||
|
||||
XCTMain([
|
||||
// HTTPTests
|
||||
testCase(VersionTests.allTests),
|
||||
testCase(HeadersTests.allTests),
|
||||
testCase(ResponseTests.allTests),
|
||||
|
||||
// BlueSocketHTTPTests
|
||||
testCase(ServerTests.allTests),
|
||||
])
|
||||
|
||||
@@ -1,280 +0,0 @@
|
||||
<!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="../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>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:FO4HTTP13HTTPBodyChunk5chunkFMS0_FT4dataV8Dispatch12DispatchData18finishedProcessingFT_T__S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/chunk" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP13HTTPBodyChunk5chunkFMS0_FT4dataV8Dispatch12DispatchData18finishedProcessingFT_T__S0_">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:FO4HTTP13HTTPBodyChunk6failedFMS0_FT5errorPs5Error__S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/failed" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP13HTTPBodyChunk6failedFMS0_FT5errorPs5Error__S0_">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:FO4HTTP13HTTPBodyChunk7trailerFMS0_FT3keySS5valueSS_S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/trailer" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP13HTTPBodyChunk7trailerFMS0_FT3keySS5valueSS_S0_">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:FO4HTTP13HTTPBodyChunk3endFMS0_S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/end" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP13HTTPBodyChunk3endFMS0_S0_">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.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,216 +0,0 @@
|
||||
<!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="../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>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:FO4HTTP18HTTPBodyProcessing11discardBodyFMS0_S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/discardBody" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP18HTTPBodyProcessing11discardBodyFMS0_S0_">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:FO4HTTP18HTTPBodyProcessing11processBodyFMS0_FT7handlerFTOS_13HTTPBodyChunkRSb_T__S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/processBody" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP18HTTPBodyProcessing11processBodyFMS0_FT7handlerFTOS_13HTTPBodyChunkRSb_T__S0_">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:4HTTP15HTTPBodyHandler">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:4HTTP15HTTPBodyHandler">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.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,216 +0,0 @@
|
||||
<!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="../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>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:FO4HTTP6Result2okFMS0_S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/ok" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP6Result2okFMS0_S0_">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:FO4HTTP6Result5errorFMS0_FPs5Error_S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/error" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP6Result5errorFMS0_FPs5Error_S0_">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.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,217 +0,0 @@
|
||||
<!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="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>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:V4HTTP11HTTPHeaders"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPHeaders" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:V4HTTP11HTTPHeaders">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:V4HTTP11HTTPVersion"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPVersion" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:V4HTTP11HTTPVersion">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.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,324 +0,0 @@
|
||||
<!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="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>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:V4HTTP11HTTPRequest"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPRequest" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:V4HTTP11HTTPRequest">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:4HTTP15HTTPBodyHandler"></a>
|
||||
<a name="//apple_ref/swift/Alias/HTTPBodyHandler" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP15HTTPBodyHandler">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 ResponseWriter</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>Bool 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:O4HTTP18HTTPBodyProcessing"></a>
|
||||
<a name="//apple_ref/swift/Enum/HTTPBodyProcessing" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:O4HTTP18HTTPBodyProcessing">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:O4HTTP13HTTPBodyChunk"></a>
|
||||
<a name="//apple_ref/swift/Enum/HTTPBodyChunk" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:O4HTTP13HTTPBodyChunk">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:V4HTTP10HTTPMethod"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPMethod" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:V4HTTP10HTTPMethod">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.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,239 +0,0 @@
|
||||
<!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="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>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:V4HTTP12HTTPResponse"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPResponse" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:V4HTTP12HTTPResponse">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:V4HTTP18HTTPResponseStatus"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPResponseStatus" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:V4HTTP18HTTPResponseStatus">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:P4HTTP18HTTPResponseWriter"></a>
|
||||
<a name="//apple_ref/swift/Protocol/HTTPResponseWriter" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:P4HTTP18HTTPResponseWriter">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.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,256 +0,0 @@
|
||||
<!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="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>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:P4HTTP16WebAppContaining"></a>
|
||||
<a name="//apple_ref/swift/Protocol/WebAppContaining" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:P4HTTP16WebAppContaining">WebAppContaining</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 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>
|
||||
|
||||
<a href="Protocols/WebAppContaining.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">WebAppContaining</span><span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP6WebApp"></a>
|
||||
<a name="//apple_ref/swift/Alias/WebApp" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP6WebApp">WebApp</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</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">WebApp</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>
|
||||
</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,179 +0,0 @@
|
||||
<!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="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>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:O4HTTP6Result"></a>
|
||||
<a name="//apple_ref/swift/Enum/Result" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:O4HTTP6Result">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.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,597 +0,0 @@
|
||||
<!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="../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>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:FP4HTTP18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus7headersVS_11HTTPHeaders10completionFOS_6ResultT__T_"></a>
|
||||
<a name="//apple_ref/swift/Method/writeHeader(status:headers:completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FP4HTTP18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus7headersVS_11HTTPHeaders10completionFOS_6ResultT__T_">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>writeHeader: 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:FP4HTTP18HTTPResponseWriter12writeTrailerFTVS_11HTTPHeaders10completionFOS_6ResultT__T_"></a>
|
||||
<a name="//apple_ref/swift/Method/writeTrailer(_:completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FP4HTTP18HTTPResponseWriter12writeTrailerFTVS_11HTTPHeaders10completionFOS_6ResultT__T_">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>writeTrailer: 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:FP4HTTP18HTTPResponseWriter9writeBodyFTPS_22UnsafeHTTPResponseBody_10completionFOS_6ResultT__T_"></a>
|
||||
<a name="//apple_ref/swift/Method/writeBody(_:completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FP4HTTP18HTTPResponseWriter9writeBodyFTPS_22UnsafeHTTPResponseBody_10completionFOS_6ResultT__T_">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>writeBody: 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:FP4HTTP18HTTPResponseWriter4doneFT10completionFOS_6ResultT__T_"></a>
|
||||
<a name="//apple_ref/swift/Method/done(completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FP4HTTP18HTTPResponseWriter4doneFT10completionFOS_6ResultT__T_">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>done: 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:FP4HTTP18HTTPResponseWriter5abortFT_T_"></a>
|
||||
<a name="//apple_ref/swift/Method/abort()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FP4HTTP18HTTPResponseWriter5abortFT_T_">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:FE4HTTPPS_18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus7headersVS_11HTTPHeaders_T_"></a>
|
||||
<a name="//apple_ref/swift/Method/writeHeader(status:headers:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FE4HTTPPS_18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus7headersVS_11HTTPHeaders_T_">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 funtion 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:FP4HTTP18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus7headersVS_11HTTPHeaders10completionFOS_6ResultT__T_">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:FE4HTTPPS_18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus_T_"></a>
|
||||
<a name="//apple_ref/swift/Method/writeHeader(status:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FE4HTTPPS_18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus_T_">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 funtion 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:FP4HTTP18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus7headersVS_11HTTPHeaders10completionFOS_6ResultT__T_">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:FE4HTTPPS_18HTTPResponseWriter12writeTrailerFVS_11HTTPHeadersT_"></a>
|
||||
<a name="//apple_ref/swift/Method/writeTrailer(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FE4HTTPPS_18HTTPResponseWriter12writeTrailerFVS_11HTTPHeadersT_">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:FP4HTTP18HTTPResponseWriter12writeTrailerFTVS_11HTTPHeaders10completionFOS_6ResultT__T_">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:FE4HTTPPS_18HTTPResponseWriter9writeBodyFPS_22UnsafeHTTPResponseBody_T_"></a>
|
||||
<a name="//apple_ref/swift/Method/writeBody(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FE4HTTPPS_18HTTPResponseWriter9writeBodyFPS_22UnsafeHTTPResponseBody_T_">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:FE4HTTPPS_18HTTPResponseWriter4doneFT_T_"></a>
|
||||
<a name="//apple_ref/swift/Method/done()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FE4HTTPPS_18HTTPResponseWriter4doneFT_T_">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.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,236 +0,0 @@
|
||||
<!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,282 +0,0 @@
|
||||
<!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="../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>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:FV4HTTP11HTTPHeaderscFt17dictionaryLiteralGSaTVS0_4NameSS___S0_"></a>
|
||||
<a name="//apple_ref/swift/Method/init(dictionaryLiteral:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FV4HTTP11HTTPHeaderscFt17dictionaryLiteralGSaTVS0_4NameSS___S0_">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:FV4HTTP11HTTPHeaders6appendFVS0_7LiteralT_"></a>
|
||||
<a name="//apple_ref/swift/Method/append(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FV4HTTP11HTTPHeaders6appendFVS0_7LiteralT_">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:FV4HTTP11HTTPHeaders7replaceFVS0_7LiteralT_"></a>
|
||||
<a name="//apple_ref/swift/Method/replace(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FV4HTTP11HTTPHeaders7replaceFVS0_7LiteralT_">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:VV4HTTP11HTTPHeaders4Name"></a>
|
||||
<a name="//apple_ref/swift/Struct/Name" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:VV4HTTP11HTTPHeaders4Name">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.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,266 +0,0 @@
|
||||
<!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="../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>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:vV4HTTP11HTTPRequest6methodVS_10HTTPMethod"></a>
|
||||
<a name="//apple_ref/swift/Property/method" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP11HTTPRequest6methodVS_10HTTPMethod">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:vV4HTTP11HTTPRequest6targetSS"></a>
|
||||
<a name="//apple_ref/swift/Property/target" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP11HTTPRequest6targetSS">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:vV4HTTP11HTTPRequest11httpVersionVS_11HTTPVersion"></a>
|
||||
<a name="//apple_ref/swift/Property/httpVersion" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP11HTTPRequest11httpVersionVS_11HTTPVersion">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:vV4HTTP11HTTPRequest7headersVS_11HTTPHeaders"></a>
|
||||
<a name="//apple_ref/swift/Property/headers" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP11HTTPRequest7headersVS_11HTTPHeaders">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.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,239 +0,0 @@
|
||||
<!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="../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>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:vV4HTTP12HTTPResponse11httpVersionVS_11HTTPVersion"></a>
|
||||
<a name="//apple_ref/swift/Property/httpVersion" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP12HTTPResponse11httpVersionVS_11HTTPVersion">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:vV4HTTP12HTTPResponse6statusVS_18HTTPResponseStatus"></a>
|
||||
<a name="//apple_ref/swift/Property/status" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP12HTTPResponse6statusVS_18HTTPResponseStatus">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:vV4HTTP12HTTPResponse7headersVS_11HTTPHeaders"></a>
|
||||
<a name="//apple_ref/swift/Property/headers" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP12HTTPResponse7headersVS_11HTTPHeaders">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.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,345 +0,0 @@
|
||||
<!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="../../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>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:FOV4HTTP18HTTPResponseStatus5Class13informationalFMS1_S1_"></a>
|
||||
<a name="//apple_ref/swift/Element/informational" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FOV4HTTP18HTTPResponseStatus5Class13informationalFMS1_S1_">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:FOV4HTTP18HTTPResponseStatus5Class10successfulFMS1_S1_"></a>
|
||||
<a name="//apple_ref/swift/Element/successful" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FOV4HTTP18HTTPResponseStatus5Class10successfulFMS1_S1_">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:FOV4HTTP18HTTPResponseStatus5Class11redirectionFMS1_S1_"></a>
|
||||
<a name="//apple_ref/swift/Element/redirection" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FOV4HTTP18HTTPResponseStatus5Class11redirectionFMS1_S1_">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:FOV4HTTP18HTTPResponseStatus5Class11clientErrorFMS1_S1_"></a>
|
||||
<a name="//apple_ref/swift/Element/clientError" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FOV4HTTP18HTTPResponseStatus5Class11clientErrorFMS1_S1_">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:FOV4HTTP18HTTPResponseStatus5Class11serverErrorFMS1_S1_"></a>
|
||||
<a name="//apple_ref/swift/Element/serverError" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FOV4HTTP18HTTPResponseStatus5Class11serverErrorFMS1_S1_">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:FOV4HTTP18HTTPResponseStatus5Class13invalidStatusFMS1_S1_"></a>
|
||||
<a name="//apple_ref/swift/Element/invalidStatus" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FOV4HTTP18HTTPResponseStatus5Class13invalidStatusFMS1_S1_">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.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,239 +0,0 @@
|
||||
<!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="../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>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:vV4HTTP11HTTPVersion5majorSi"></a>
|
||||
<a name="//apple_ref/swift/Property/major" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP11HTTPVersion5majorSi">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:vV4HTTP11HTTPVersion5minorSi"></a>
|
||||
<a name="//apple_ref/swift/Property/minor" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP11HTTPVersion5minorSi">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:FV4HTTP11HTTPVersioncFT5majorSi5minorSi_S0_"></a>
|
||||
<a name="//apple_ref/swift/Method/init(major:minor:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FV4HTTP11HTTPVersioncFT5majorSi5minorSi_S0_">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.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 +0,0 @@
|
||||
<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>
|
||||
|
Before Width: | Height: | Size: 807 B |
@@ -1,200 +0,0 @@
|
||||
/* 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; }
|
||||
@@ -1,368 +0,0 @@
|
||||
*, *: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; }
|
||||
@@ -1,20 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,280 +0,0 @@
|
||||
<!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="../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>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:FO4HTTP13HTTPBodyChunk5chunkFMS0_FT4dataV8Dispatch12DispatchData18finishedProcessingFT_T__S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/chunk" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP13HTTPBodyChunk5chunkFMS0_FT4dataV8Dispatch12DispatchData18finishedProcessingFT_T__S0_">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:FO4HTTP13HTTPBodyChunk6failedFMS0_FT5errorPs5Error__S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/failed" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP13HTTPBodyChunk6failedFMS0_FT5errorPs5Error__S0_">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:FO4HTTP13HTTPBodyChunk7trailerFMS0_FT3keySS5valueSS_S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/trailer" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP13HTTPBodyChunk7trailerFMS0_FT3keySS5valueSS_S0_">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:FO4HTTP13HTTPBodyChunk3endFMS0_S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/end" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP13HTTPBodyChunk3endFMS0_S0_">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.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,216 +0,0 @@
|
||||
<!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="../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>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:FO4HTTP18HTTPBodyProcessing11discardBodyFMS0_S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/discardBody" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP18HTTPBodyProcessing11discardBodyFMS0_S0_">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:FO4HTTP18HTTPBodyProcessing11processBodyFMS0_FT7handlerFTOS_13HTTPBodyChunkRSb_T__S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/processBody" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP18HTTPBodyProcessing11processBodyFMS0_FT7handlerFTOS_13HTTPBodyChunkRSb_T__S0_">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:4HTTP15HTTPBodyHandler">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:4HTTP15HTTPBodyHandler">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.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,216 +0,0 @@
|
||||
<!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="../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>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:FO4HTTP6Result2okFMS0_S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/ok" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP6Result2okFMS0_S0_">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:FO4HTTP6Result5errorFMS0_FPs5Error_S0_"></a>
|
||||
<a name="//apple_ref/swift/Element/error" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FO4HTTP6Result5errorFMS0_FPs5Error_S0_">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.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,217 +0,0 @@
|
||||
<!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="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>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:V4HTTP11HTTPHeaders"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPHeaders" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:V4HTTP11HTTPHeaders">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:V4HTTP11HTTPVersion"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPVersion" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:V4HTTP11HTTPVersion">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.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,324 +0,0 @@
|
||||
<!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="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>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:V4HTTP11HTTPRequest"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPRequest" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:V4HTTP11HTTPRequest">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:4HTTP15HTTPBodyHandler"></a>
|
||||
<a name="//apple_ref/swift/Alias/HTTPBodyHandler" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP15HTTPBodyHandler">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 ResponseWriter</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>Bool 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:O4HTTP18HTTPBodyProcessing"></a>
|
||||
<a name="//apple_ref/swift/Enum/HTTPBodyProcessing" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:O4HTTP18HTTPBodyProcessing">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:O4HTTP13HTTPBodyChunk"></a>
|
||||
<a name="//apple_ref/swift/Enum/HTTPBodyChunk" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:O4HTTP13HTTPBodyChunk">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:V4HTTP10HTTPMethod"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPMethod" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:V4HTTP10HTTPMethod">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.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,239 +0,0 @@
|
||||
<!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="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>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:V4HTTP12HTTPResponse"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPResponse" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:V4HTTP12HTTPResponse">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:V4HTTP18HTTPResponseStatus"></a>
|
||||
<a name="//apple_ref/swift/Struct/HTTPResponseStatus" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:V4HTTP18HTTPResponseStatus">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:P4HTTP18HTTPResponseWriter"></a>
|
||||
<a name="//apple_ref/swift/Protocol/HTTPResponseWriter" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:P4HTTP18HTTPResponseWriter">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.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,256 +0,0 @@
|
||||
<!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="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>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:P4HTTP16WebAppContaining"></a>
|
||||
<a name="//apple_ref/swift/Protocol/WebAppContaining" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:P4HTTP16WebAppContaining">WebAppContaining</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 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>
|
||||
|
||||
<a href="Protocols/WebAppContaining.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">WebAppContaining</span><span class="p">:</span> <span class="kd">class</span></code></pre>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</li>
|
||||
<li class="item">
|
||||
<div>
|
||||
<code>
|
||||
<a name="/s:4HTTP6WebApp"></a>
|
||||
<a name="//apple_ref/swift/Alias/WebApp" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:4HTTP6WebApp">WebApp</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</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">WebApp</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>
|
||||
</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,179 +0,0 @@
|
||||
<!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="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>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:O4HTTP6Result"></a>
|
||||
<a name="//apple_ref/swift/Enum/Result" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:O4HTTP6Result">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.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,597 +0,0 @@
|
||||
<!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="../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>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:FP4HTTP18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus7headersVS_11HTTPHeaders10completionFOS_6ResultT__T_"></a>
|
||||
<a name="//apple_ref/swift/Method/writeHeader(status:headers:completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FP4HTTP18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus7headersVS_11HTTPHeaders10completionFOS_6ResultT__T_">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>writeHeader: 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:FP4HTTP18HTTPResponseWriter12writeTrailerFTVS_11HTTPHeaders10completionFOS_6ResultT__T_"></a>
|
||||
<a name="//apple_ref/swift/Method/writeTrailer(_:completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FP4HTTP18HTTPResponseWriter12writeTrailerFTVS_11HTTPHeaders10completionFOS_6ResultT__T_">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>writeTrailer: 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:FP4HTTP18HTTPResponseWriter9writeBodyFTPS_22UnsafeHTTPResponseBody_10completionFOS_6ResultT__T_"></a>
|
||||
<a name="//apple_ref/swift/Method/writeBody(_:completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FP4HTTP18HTTPResponseWriter9writeBodyFTPS_22UnsafeHTTPResponseBody_10completionFOS_6ResultT__T_">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>writeBody: 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:FP4HTTP18HTTPResponseWriter4doneFT10completionFOS_6ResultT__T_"></a>
|
||||
<a name="//apple_ref/swift/Method/done(completion:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FP4HTTP18HTTPResponseWriter4doneFT10completionFOS_6ResultT__T_">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>done: 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:FP4HTTP18HTTPResponseWriter5abortFT_T_"></a>
|
||||
<a name="//apple_ref/swift/Method/abort()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FP4HTTP18HTTPResponseWriter5abortFT_T_">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:FE4HTTPPS_18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus7headersVS_11HTTPHeaders_T_"></a>
|
||||
<a name="//apple_ref/swift/Method/writeHeader(status:headers:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FE4HTTPPS_18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus7headersVS_11HTTPHeaders_T_">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 funtion 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:FP4HTTP18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus7headersVS_11HTTPHeaders10completionFOS_6ResultT__T_">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:FE4HTTPPS_18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus_T_"></a>
|
||||
<a name="//apple_ref/swift/Method/writeHeader(status:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FE4HTTPPS_18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus_T_">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 funtion 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:FP4HTTP18HTTPResponseWriter11writeHeaderFT6statusVS_18HTTPResponseStatus7headersVS_11HTTPHeaders10completionFOS_6ResultT__T_">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:FE4HTTPPS_18HTTPResponseWriter12writeTrailerFVS_11HTTPHeadersT_"></a>
|
||||
<a name="//apple_ref/swift/Method/writeTrailer(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FE4HTTPPS_18HTTPResponseWriter12writeTrailerFVS_11HTTPHeadersT_">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:FP4HTTP18HTTPResponseWriter12writeTrailerFTVS_11HTTPHeaders10completionFOS_6ResultT__T_">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:FE4HTTPPS_18HTTPResponseWriter9writeBodyFPS_22UnsafeHTTPResponseBody_T_"></a>
|
||||
<a name="//apple_ref/swift/Method/writeBody(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FE4HTTPPS_18HTTPResponseWriter9writeBodyFPS_22UnsafeHTTPResponseBody_T_">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:FE4HTTPPS_18HTTPResponseWriter4doneFT_T_"></a>
|
||||
<a name="//apple_ref/swift/Method/done()" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FE4HTTPPS_18HTTPResponseWriter4doneFT_T_">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.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,236 +0,0 @@
|
||||
<!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,282 +0,0 @@
|
||||
<!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="../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>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:FV4HTTP11HTTPHeaderscFt17dictionaryLiteralGSaTVS0_4NameSS___S0_"></a>
|
||||
<a name="//apple_ref/swift/Method/init(dictionaryLiteral:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FV4HTTP11HTTPHeaderscFt17dictionaryLiteralGSaTVS0_4NameSS___S0_">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:FV4HTTP11HTTPHeaders6appendFVS0_7LiteralT_"></a>
|
||||
<a name="//apple_ref/swift/Method/append(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FV4HTTP11HTTPHeaders6appendFVS0_7LiteralT_">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:FV4HTTP11HTTPHeaders7replaceFVS0_7LiteralT_"></a>
|
||||
<a name="//apple_ref/swift/Method/replace(_:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FV4HTTP11HTTPHeaders7replaceFVS0_7LiteralT_">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:VV4HTTP11HTTPHeaders4Name"></a>
|
||||
<a name="//apple_ref/swift/Struct/Name" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:VV4HTTP11HTTPHeaders4Name">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.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,266 +0,0 @@
|
||||
<!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="../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>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:vV4HTTP11HTTPRequest6methodVS_10HTTPMethod"></a>
|
||||
<a name="//apple_ref/swift/Property/method" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP11HTTPRequest6methodVS_10HTTPMethod">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:vV4HTTP11HTTPRequest6targetSS"></a>
|
||||
<a name="//apple_ref/swift/Property/target" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP11HTTPRequest6targetSS">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:vV4HTTP11HTTPRequest11httpVersionVS_11HTTPVersion"></a>
|
||||
<a name="//apple_ref/swift/Property/httpVersion" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP11HTTPRequest11httpVersionVS_11HTTPVersion">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:vV4HTTP11HTTPRequest7headersVS_11HTTPHeaders"></a>
|
||||
<a name="//apple_ref/swift/Property/headers" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP11HTTPRequest7headersVS_11HTTPHeaders">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.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,239 +0,0 @@
|
||||
<!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="../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>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:vV4HTTP12HTTPResponse11httpVersionVS_11HTTPVersion"></a>
|
||||
<a name="//apple_ref/swift/Property/httpVersion" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP12HTTPResponse11httpVersionVS_11HTTPVersion">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:vV4HTTP12HTTPResponse6statusVS_18HTTPResponseStatus"></a>
|
||||
<a name="//apple_ref/swift/Property/status" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP12HTTPResponse6statusVS_18HTTPResponseStatus">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:vV4HTTP12HTTPResponse7headersVS_11HTTPHeaders"></a>
|
||||
<a name="//apple_ref/swift/Property/headers" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP12HTTPResponse7headersVS_11HTTPHeaders">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.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,345 +0,0 @@
|
||||
<!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="../../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>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:FOV4HTTP18HTTPResponseStatus5Class13informationalFMS1_S1_"></a>
|
||||
<a name="//apple_ref/swift/Element/informational" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FOV4HTTP18HTTPResponseStatus5Class13informationalFMS1_S1_">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:FOV4HTTP18HTTPResponseStatus5Class10successfulFMS1_S1_"></a>
|
||||
<a name="//apple_ref/swift/Element/successful" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FOV4HTTP18HTTPResponseStatus5Class10successfulFMS1_S1_">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:FOV4HTTP18HTTPResponseStatus5Class11redirectionFMS1_S1_"></a>
|
||||
<a name="//apple_ref/swift/Element/redirection" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FOV4HTTP18HTTPResponseStatus5Class11redirectionFMS1_S1_">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:FOV4HTTP18HTTPResponseStatus5Class11clientErrorFMS1_S1_"></a>
|
||||
<a name="//apple_ref/swift/Element/clientError" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FOV4HTTP18HTTPResponseStatus5Class11clientErrorFMS1_S1_">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:FOV4HTTP18HTTPResponseStatus5Class11serverErrorFMS1_S1_"></a>
|
||||
<a name="//apple_ref/swift/Element/serverError" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FOV4HTTP18HTTPResponseStatus5Class11serverErrorFMS1_S1_">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:FOV4HTTP18HTTPResponseStatus5Class13invalidStatusFMS1_S1_"></a>
|
||||
<a name="//apple_ref/swift/Element/invalidStatus" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FOV4HTTP18HTTPResponseStatus5Class13invalidStatusFMS1_S1_">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.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,239 +0,0 @@
|
||||
<!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="../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>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:vV4HTTP11HTTPVersion5majorSi"></a>
|
||||
<a name="//apple_ref/swift/Property/major" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP11HTTPVersion5majorSi">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:vV4HTTP11HTTPVersion5minorSi"></a>
|
||||
<a name="//apple_ref/swift/Property/minor" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:vV4HTTP11HTTPVersion5minorSi">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:FV4HTTP11HTTPVersioncFT5majorSi5minorSi_S0_"></a>
|
||||
<a name="//apple_ref/swift/Method/init(major:minor:)" class="dashAnchor"></a>
|
||||
<a class="token" href="#/s:FV4HTTP11HTTPVersioncFT5majorSi5minorSi_S0_">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.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,200 +0,0 @@
|
||||
/* 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; }
|
||||
@@ -1,368 +0,0 @@
|
||||
*, *: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; }
|
||||
|
Before Width: | Height: | Size: 274 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
@@ -1,145 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTP 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 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 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 id='swiftserverhttp' class='heading'>SwiftServerHttp</h1>
|
||||
|
||||
<p>Sample prototype implementation of @weissi’s HTTP Sketch v2 from <a href="https://lists.swift.org/pipermail/swift-server-dev/Week-of-Mon-20170403/000422.html">https://lists.swift.org/pipermail/swift-server-dev/Week-of-Mon-20170403/000422.html</a> for discussion.</p>
|
||||
|
||||
</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,43 +0,0 @@
|
||||
window.jazzy = {'docset': false}
|
||||
if (typeof window.dash != 'undefined') {
|
||||
document.documentElement.className += ' dash'
|
||||
window.jazzy.docset = true
|
||||
}
|
||||
if (navigator.userAgent.match(/xcode/i)) {
|
||||
document.documentElement.className += ' xcode'
|
||||
window.jazzy.docset = true
|
||||
}
|
||||
|
||||
// On doc load, toggle the URL hash discussion if present
|
||||
$(document).ready(function() {
|
||||
if (!window.jazzy.docset) {
|
||||
var linkToHash = $('a[href="' + window.location.hash +'"]');
|
||||
linkToHash.trigger("click");
|
||||
}
|
||||
});
|
||||
|
||||
// On token click, toggle its discussion and animate token.marginLeft
|
||||
$(".token").click(function(event) {
|
||||
if (window.jazzy.docset) {
|
||||
return;
|
||||
}
|
||||
var link = $(this);
|
||||
var animationDuration = 300;
|
||||
$content = link.parent().parent().next();
|
||||
$content.slideToggle(animationDuration);
|
||||
|
||||
// Keeps the document from jumping to the hash.
|
||||
var href = $(this).attr('href');
|
||||
if (history.pushState) {
|
||||
history.pushState({}, '', href);
|
||||
} else {
|
||||
location.hash = href;
|
||||
}
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// Dumb down quotes within code blocks that delimit strings instead of quotations
|
||||
// https://github.com/realm/jazzy/issues/714
|
||||
$("code q").replaceWith(function () {
|
||||
return ["\"", $(this).contents(), "\""];
|
||||
});
|
||||
@@ -1,62 +0,0 @@
|
||||
$(function(){
|
||||
var searchIndex = lunr(function() {
|
||||
this.ref('url');
|
||||
this.field('name');
|
||||
});
|
||||
|
||||
var $typeahead = $('[data-typeahead]');
|
||||
var $form = $typeahead.parents('form');
|
||||
var searchURL = $form.attr('action');
|
||||
|
||||
function displayTemplate(result) {
|
||||
return result.name;
|
||||
}
|
||||
|
||||
function suggestionTemplate(result) {
|
||||
var t = '<div class="list-group-item clearfix">';
|
||||
t += '<span class="doc-name">' + result.name + '</span>';
|
||||
if (result.parent_name) {
|
||||
t += '<span class="doc-parent-name label">' + result.parent_name + '</span>';
|
||||
}
|
||||
t += '</div>';
|
||||
return t;
|
||||
}
|
||||
|
||||
$typeahead.one('focus', function() {
|
||||
$form.addClass('loading');
|
||||
|
||||
$.getJSON(searchURL).then(function(searchData) {
|
||||
$.each(searchData, function (url, doc) {
|
||||
searchIndex.add({url: url, name: doc.name});
|
||||
});
|
||||
|
||||
$typeahead.typeahead(
|
||||
{
|
||||
highlight: true,
|
||||
minLength: 3
|
||||
},
|
||||
{
|
||||
limit: 10,
|
||||
display: displayTemplate,
|
||||
templates: { suggestion: suggestionTemplate },
|
||||
source: function(query, sync) {
|
||||
var results = searchIndex.search(query).map(function(result) {
|
||||
var doc = searchData[result.ref];
|
||||
doc.url = result.ref;
|
||||
return doc;
|
||||
});
|
||||
sync(results);
|
||||
}
|
||||
}
|
||||
);
|
||||
$form.removeClass('loading');
|
||||
$typeahead.trigger('focus');
|
||||
});
|
||||
});
|
||||
|
||||
var baseURL = searchURL.slice(0, -"search.json".length);
|
||||
|
||||
$typeahead.on('typeahead:select', function(e, result) {
|
||||
window.location = baseURL + result.url;
|
||||
});
|
||||
});
|
||||
|
Before Width: | Height: | Size: 274 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
@@ -1,145 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>HTTP 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 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 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 id='swiftserverhttp' class='heading'>SwiftServerHttp</h1>
|
||||
|
||||
<p>Sample prototype implementation of @weissi’s HTTP Sketch v2 from <a href="https://lists.swift.org/pipermail/swift-server-dev/Week-of-Mon-20170403/000422.html">https://lists.swift.org/pipermail/swift-server-dev/Week-of-Mon-20170403/000422.html</a> for discussion.</p>
|
||||
|
||||
</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,43 +0,0 @@
|
||||
window.jazzy = {'docset': false}
|
||||
if (typeof window.dash != 'undefined') {
|
||||
document.documentElement.className += ' dash'
|
||||
window.jazzy.docset = true
|
||||
}
|
||||
if (navigator.userAgent.match(/xcode/i)) {
|
||||
document.documentElement.className += ' xcode'
|
||||
window.jazzy.docset = true
|
||||
}
|
||||
|
||||
// On doc load, toggle the URL hash discussion if present
|
||||
$(document).ready(function() {
|
||||
if (!window.jazzy.docset) {
|
||||
var linkToHash = $('a[href="' + window.location.hash +'"]');
|
||||
linkToHash.trigger("click");
|
||||
}
|
||||
});
|
||||
|
||||
// On token click, toggle its discussion and animate token.marginLeft
|
||||
$(".token").click(function(event) {
|
||||
if (window.jazzy.docset) {
|
||||
return;
|
||||
}
|
||||
var link = $(this);
|
||||
var animationDuration = 300;
|
||||
$content = link.parent().parent().next();
|
||||
$content.slideToggle(animationDuration);
|
||||
|
||||
// Keeps the document from jumping to the hash.
|
||||
var href = $(this).attr('href');
|
||||
if (history.pushState) {
|
||||
history.pushState({}, '', href);
|
||||
} else {
|
||||
location.hash = href;
|
||||
}
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// Dumb down quotes within code blocks that delimit strings instead of quotations
|
||||
// https://github.com/realm/jazzy/issues/714
|
||||
$("code q").replaceWith(function () {
|
||||
return ["\"", $(this).contents(), "\""];
|
||||
});
|
||||
@@ -1,62 +0,0 @@
|
||||
$(function(){
|
||||
var searchIndex = lunr(function() {
|
||||
this.ref('url');
|
||||
this.field('name');
|
||||
});
|
||||
|
||||
var $typeahead = $('[data-typeahead]');
|
||||
var $form = $typeahead.parents('form');
|
||||
var searchURL = $form.attr('action');
|
||||
|
||||
function displayTemplate(result) {
|
||||
return result.name;
|
||||
}
|
||||
|
||||
function suggestionTemplate(result) {
|
||||
var t = '<div class="list-group-item clearfix">';
|
||||
t += '<span class="doc-name">' + result.name + '</span>';
|
||||
if (result.parent_name) {
|
||||
t += '<span class="doc-parent-name label">' + result.parent_name + '</span>';
|
||||
}
|
||||
t += '</div>';
|
||||
return t;
|
||||
}
|
||||
|
||||
$typeahead.one('focus', function() {
|
||||
$form.addClass('loading');
|
||||
|
||||
$.getJSON(searchURL).then(function(searchData) {
|
||||
$.each(searchData, function (url, doc) {
|
||||
searchIndex.add({url: url, name: doc.name});
|
||||
});
|
||||
|
||||
$typeahead.typeahead(
|
||||
{
|
||||
highlight: true,
|
||||
minLength: 3
|
||||
},
|
||||
{
|
||||
limit: 10,
|
||||
display: displayTemplate,
|
||||
templates: { suggestion: suggestionTemplate },
|
||||
source: function(query, sync) {
|
||||
var results = searchIndex.search(query).map(function(result) {
|
||||
var doc = searchData[result.ref];
|
||||
doc.url = result.ref;
|
||||
return doc;
|
||||
});
|
||||
sync(results);
|
||||
}
|
||||
}
|
||||
);
|
||||
$form.removeClass('loading');
|
||||
$typeahead.trigger('focus');
|
||||
});
|
||||
});
|
||||
|
||||
var baseURL = searchURL.slice(0, -"search.json".length);
|
||||
|
||||
$typeahead.on('typeahead:select', function(e, result) {
|
||||
window.location = baseURL + result.url;
|
||||
});
|
||||
});
|
||||