Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07cd40ce8c | ||
|
|
8a5668cc19 | ||
|
|
21cf431cf1 | ||
|
|
6b8cd8b092 | ||
|
|
7bf242651c | ||
|
|
30344ad3f0 | ||
|
|
9b64bc21d8 | ||
|
|
b5001e49c6 | ||
|
|
3739ce6037 | ||
|
|
36adb9f32f | ||
|
|
66c6b6a06d | ||
|
|
b576f2e860 | ||
|
|
3af439047d | ||
|
|
933ecc536b | ||
|
|
dd00ed6e3b | ||
|
|
31d066a0e9 | ||
|
|
e002bc58eb | ||
|
|
d50eeecf76 | ||
|
|
4eab465956 | ||
|
|
92dcc60699 | ||
|
|
825b680c64 | ||
|
|
2e987e181c | ||
|
|
397c5fb7a4 | ||
|
|
b6211a2894 | ||
|
|
4d2c2b55f7 | ||
|
|
b54c7b40ad | ||
|
|
9dd0946bff | ||
|
|
a5a4da0375 | ||
|
|
6ad4650c17 | ||
|
|
2c4336880d | ||
|
|
b624e39530 | ||
|
|
53e1e38e1b | ||
|
|
630bd0bfc9 | ||
|
|
728b66d569 | ||
|
|
88ab09d047 | ||
|
|
473177815d | ||
|
|
fa11340bc1 | ||
|
|
34cd525151 | ||
|
|
d9dbb40531 | ||
|
|
1994157441 | ||
|
|
ec6087c2a1 | ||
|
|
fb6df9b933 | ||
|
|
5a00cde492 | ||
|
|
fffb8dd883 | ||
|
|
234551eeef | ||
|
|
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,5 @@ fastlane/test_output
|
|||||||
*.orig
|
*.orig
|
||||||
/.idea
|
/.idea
|
||||||
/Package.pins
|
/Package.pins
|
||||||
|
/Package.resolved
|
||||||
|
docs
|
||||||
|
|||||||
+5
-3
@@ -12,14 +12,16 @@ readme: README.md
|
|||||||
skip_undocumented: false
|
skip_undocumented: false
|
||||||
hide_documentation_coverage: 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:
|
custom_categories:
|
||||||
|
|
||||||
- name: HTTP Server
|
- name: HTTP Server
|
||||||
children:
|
children:
|
||||||
- WebAppContaining
|
- HTTPServer
|
||||||
- WebApp
|
- HTTPServing
|
||||||
|
- HTTPRequestHandler
|
||||||
|
- HTTPRequestHandling
|
||||||
|
|
||||||
- name: HTTP Headers
|
- name: HTTP Headers
|
||||||
children:
|
children:
|
||||||
|
|||||||
+1
-1
@@ -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
|
||||||
+24
@@ -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
|
||||||
@@ -385,7 +385,7 @@ public struct HTTPMethod : Hashable, CustomStringConvertible, ExpressibleByInteg
|
|||||||
public static let trace
|
public static let trace
|
||||||
public static let copy
|
public static let copy
|
||||||
public static let lock
|
public static let lock
|
||||||
public static let mkol
|
public static let mkcol
|
||||||
public static let move
|
public static let move
|
||||||
public static let propfind
|
public static let propfind
|
||||||
public static let proppatch
|
public static let proppatch
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
# Create self-signed certificate with openssl
|
||||||
|
|
||||||
|
```
|
||||||
|
// generate an RSA key
|
||||||
|
openssl genrsa -out key.pem 2048
|
||||||
|
|
||||||
|
// create cert signing request used to generate the cert
|
||||||
|
openssl req -new -sha256 -key key.pem -out cert.csr
|
||||||
|
|
||||||
|
// create cert
|
||||||
|
openssl req -x509 -sha256 -days 365 -key key.pem -in cert.csr -out cert.pem
|
||||||
|
|
||||||
|
// convert cert into PKCS#12 format:
|
||||||
|
openssl pkcs12 -export -out cert.pfx -inkey key.pem -in cert.pem
|
||||||
|
```
|
||||||
|
sw!ft!sC00l
|
||||||
|
|
||||||
|
Alternatively, use: https://www.sslshopper.com/ssl-converter.html
|
||||||
|
|
||||||
|
# Create certificate chain CA->intermediate->server
|
||||||
|
// Based on https://jamielinux.com/docs/openssl-certificate-authority/introduction.html
|
||||||
|
// Use above link to
|
||||||
|
|
||||||
|
```
|
||||||
|
// create root key
|
||||||
|
openssl genrsa -out ca.key.pem 4096
|
||||||
|
|
||||||
|
//create root certificate
|
||||||
|
openssl req -config openssl.cnf -key ca.key.pem -new -x509 -days 7300 -sha256 extensions v3_ca -out ca.cert.pem
|
||||||
|
|
||||||
|
//verify root cert
|
||||||
|
openssl x509 -noout -text -in ca.cert.pem
|
||||||
|
|
||||||
|
// create intermediate key
|
||||||
|
openssl genrsa -out intermediate/intermediate.key.pem 4096
|
||||||
|
|
||||||
|
// create a certificate signing request
|
||||||
|
openssl req -config intermediate/openssl.cnf -new -sha256 -key intermediate/intermediate.key.pem -out intermediate/intermediate.csr.pem
|
||||||
|
|
||||||
|
// create certificate
|
||||||
|
openssl ca -config openssl.cnf -extensions v3_intermediate_ca -days 3650 -notext -md sha256 -in intermediate/intermediate.csr.pem -out intermediate/intermediate.cert.pem
|
||||||
|
|
||||||
|
// verify intermediate certificate
|
||||||
|
openssl x509 -noout -text -in intermediate/intermediate.cert.pem
|
||||||
|
|
||||||
|
// verify intermediate certificate against the root certificate
|
||||||
|
openssl verify -CAfile ca.cert.pem intermediate/intermediate.cert.pem
|
||||||
|
|
||||||
|
// create the certificate chain
|
||||||
|
cat intermediate/intermediate.cert.pem ca.cert.pem > intermediate/ca-chain.cert.pem
|
||||||
|
|
||||||
|
// create server key
|
||||||
|
openssl genrsa -out intermediate/server.key.pem 2048
|
||||||
|
|
||||||
|
openssl req -config intermediate/openssl.cnf -key intermediate/server.key.pem -new -sha256 -out intermediate/server.csr.pem
|
||||||
|
|
||||||
|
openssl ca -config intermediate/openssl.cnf -extensions server_cert -days 375 -notext -md sha256 -in intermediate/server.csr.pem -out intermediate/server.cert.pem
|
||||||
|
|
||||||
|
// verify cert
|
||||||
|
openssl x509 -noout -text -in server.cert.pem
|
||||||
|
|
||||||
|
// verify chain of trust
|
||||||
|
openssl verify -CAfile ca-chain.cert.pem server.cert.pem
|
||||||
|
|
||||||
|
|
||||||
|
// Convert to PKCS12 for testing on mac
|
||||||
|
openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt
|
||||||
|
|
||||||
|
or better yet! use: https://www.sslshopper.com/ssl-converter.html
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
-----BEGIN CERTIFICATE REQUEST-----
|
||||||
|
MIICtTCCAZ0CAQAwcDELMAkGA1UEBhMCVVMxEzARBgNVBAgTClNvbWUtU3RhdGUx
|
||||||
|
EjAQBgNVBAoTCVN3aWZ0Lm9yZzEeMBwGA1UECxMVU3dpZnQub3JnIFNlcnZlciBB
|
||||||
|
UElzMRgwFgYDVQQDEw9UTFNTZXJ2aWNlIEFQSXMwggEiMA0GCSqGSIb3DQEBAQUA
|
||||||
|
A4IBDwAwggEKAoIBAQDD+dYrPDCSrXMqK1eXReDpuf5KzMnrzhzNInCGUDQkfchv
|
||||||
|
B/sp/OzP//bnYhIGlBdlbiQyxnW30Q7I/xlfFbIs4P7Rje/szUC03/OiJM4RN36W
|
||||||
|
ry7iO38vH9LO8JlTjGhJ+AMEgdmcfhMDeuaWYUcnh3sPyQ9CLRCzFbAtvIKC9U/h
|
||||||
|
HSaBEricbvunJ91pdxTMloPwEN+5qH2lDbyuYI2mJgdxtkXuDpoOMt0qdqORyiqv
|
||||||
|
t0YUQvQyLzQCGUwiP71aBO9auVrpqE9rHcqN4N3pP0eSjMWzbUptfTNrydz06Eom
|
||||||
|
RFSeha0QKgvK4ka4J0ONvvnTqM8SJDM5Nv3WQ1s9AgMBAAGgADANBgkqhkiG9w0B
|
||||||
|
AQsFAAOCAQEANDOSLVOj7r9Ct0vHQTaP/Jm29Fm0D/C0HT5RfRpDF2NP5SPKUYU5
|
||||||
|
Gnzy4CXfIVDOLqZ5T3fCYnyAfeEBrtjO3Ygnw7Qbfu/rRJgqkX87Vq71IvEvQHls
|
||||||
|
H5JHMqBJT5m9S8fdqS04XFYZoqvrdPNp8vtFWvUjQ5m0bdw+qAE1p+RV+rWIjHnT
|
||||||
|
FZ7D+DZKjKRaanbP2iNX8wlqdg8+/HhY2MDdSscFP8EZwu7mAEIt2J0ZNuMPIN4Y
|
||||||
|
4BzzYEgh4rzWd7FwYPhl9+t3EwUSJPqo5B9Ar7CUZ1bvbVjjU63mG68Aa68S7KdZ
|
||||||
|
C3qVAaiYpRku5b1K/VAuM17/ahaFZGfhHw==
|
||||||
|
-----END CERTIFICATE REQUEST-----
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIEOzCCAyOgAwIBAgIJAPkaoUuAHqnVMA0GCSqGSIb3DQEBCwUAMHAxCzAJBgNV
|
||||||
|
BAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQKEwlTd2lmdC5vcmcx
|
||||||
|
HjAcBgNVBAsTFVN3aWZ0Lm9yZyBTZXJ2ZXIgQVBJczEYMBYGA1UEAxMPVExTU2Vy
|
||||||
|
dmljZSBBUElzMCAXDTE3MDYwNTE0MzcwNFoYDzIxMTcwNTEyMTQzNzA0WjBwMQsw
|
||||||
|
CQYDVQQGEwJVUzETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEChMJU3dpZnQu
|
||||||
|
b3JnMR4wHAYDVQQLExVTd2lmdC5vcmcgU2VydmVyIEFQSXMxGDAWBgNVBAMTD1RM
|
||||||
|
U1NlcnZpY2UgQVBJczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMP5
|
||||||
|
1is8MJKtcyorV5dF4Om5/krMyevOHM0icIZQNCR9yG8H+yn87M//9udiEgaUF2Vu
|
||||||
|
JDLGdbfRDsj/GV8Vsizg/tGN7+zNQLTf86IkzhE3fpavLuI7fy8f0s7wmVOMaEn4
|
||||||
|
AwSB2Zx+EwN65pZhRyeHew/JD0ItELMVsC28goL1T+EdJoESuJxu+6cn3Wl3FMyW
|
||||||
|
g/AQ37mofaUNvK5gjaYmB3G2Re4Omg4y3Sp2o5HKKq+3RhRC9DIvNAIZTCI/vVoE
|
||||||
|
71q5WumoT2sdyo3g3ek/R5KMxbNtSm19M2vJ3PToSiZEVJ6FrRAqC8riRrgnQ42+
|
||||||
|
+dOozxIkMzk2/dZDWz0CAwEAAaOB1TCB0jAdBgNVHQ4EFgQUjuA8rn7EEEK2aSl2
|
||||||
|
LzcHT3bIpKIwgaIGA1UdIwSBmjCBl4AUjuA8rn7EEEK2aSl2LzcHT3bIpKKhdKRy
|
||||||
|
MHAxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQKEwlT
|
||||||
|
d2lmdC5vcmcxHjAcBgNVBAsTFVN3aWZ0Lm9yZyBTZXJ2ZXIgQVBJczEYMBYGA1UE
|
||||||
|
AxMPVExTU2VydmljZSBBUElzggkA+RqhS4AeqdUwDAYDVR0TBAUwAwEB/zANBgkq
|
||||||
|
hkiG9w0BAQsFAAOCAQEAtWnk3Z3Ae6FuhGLwLAFiWQ3p+JK2mGP7BjnnyoJzuXiy
|
||||||
|
NIgMru6vJb/3O+xO3TTypRLcGHgHZgRc16VBIw4rgO2/Kr8Ij5N84L3TL+7o3hLc
|
||||||
|
0JRb+3jOADAC5LbDVKkW8li1CKFbg3H6B++9ccs72GsGSSBOCnYegUU7sc32roWo
|
||||||
|
0f1P8JjDntX4bPzzAIprVjENXx4WZf2VNGJbTsRf3lsU9/ROJwuJhuBWDDe0H657
|
||||||
|
guWIMDbxVlJoNciNH4Xxr8GNRpb97SHrgT+bNnO8uq4MT7q5xDAx452v4wJYG/B4
|
||||||
|
Iej9MelHCb0L9etQ0N9/GGJyyUD1ZDRTkup5iMsT/A==
|
||||||
|
-----END CERTIFICATE-----
|
||||||
Binary file not shown.
@@ -0,0 +1,27 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIEowIBAAKCAQEAw/nWKzwwkq1zKitXl0Xg6bn+SszJ684czSJwhlA0JH3Ibwf7
|
||||||
|
Kfzsz//252ISBpQXZW4kMsZ1t9EOyP8ZXxWyLOD+0Y3v7M1AtN/zoiTOETd+lq8u
|
||||||
|
4jt/Lx/SzvCZU4xoSfgDBIHZnH4TA3rmlmFHJ4d7D8kPQi0QsxWwLbyCgvVP4R0m
|
||||||
|
gRK4nG77pyfdaXcUzJaD8BDfuah9pQ28rmCNpiYHcbZF7g6aDjLdKnajkcoqr7dG
|
||||||
|
FEL0Mi80AhlMIj+9WgTvWrla6ahPax3KjeDd6T9HkozFs21KbX0za8nc9OhKJkRU
|
||||||
|
noWtECoLyuJGuCdDjb7506jPEiQzOTb91kNbPQIDAQABAoIBAETt/Blq6z68CTS8
|
||||||
|
1+saJfivdbTDgQYSkejJA0EKtrxbDYOYEAx9rKGgSyypPuPXdL81VUASs9b6jjO+
|
||||||
|
HiNmkyvb22TDgq8MpoS3/I58WYqOtVS0u03RVXOywsgMsjFDwm657/3G2k6DvZZM
|
||||||
|
xQwBnTBXI76ynk5NYYFL0JLVqiX7GxLHRP0vWIemi+nsLDxNuH2Z03dZcaT/crAi
|
||||||
|
C8OyxKqYjnPRQsWmfrIaqstFlB+saj41P5k1MprHFOeoYv5zRQ+vJI34X+tw/xni
|
||||||
|
vUBK6zLmF7ElffFBNSuasIVKKGVTn/NECIlPOTZcfEPaJxN9YgcK+v1Uo17IIfvr
|
||||||
|
V6HIf0ECgYEA4YCCKm0lzl4VZF8JtJhW7FnsWU5RCPPFedUmVJa+7gO1DBgqObeT
|
||||||
|
E8OL++YDoEff2m/Sb23isWqe0FYztFYZ2g/lWglznKNRjUunTIKoQ/6RdQvNPDL6
|
||||||
|
oVgr24j55JAg2Ios5HljhNyraWoJpd2jGknk/imu26Y69RkXA7VmJlECgYEA3nsO
|
||||||
|
Pkv2LjBd7VMF0yniO/q9nK/BOi0aZy4x+N7XZ6sXHPOqYdnHhI1tVK37z0+NEe2P
|
||||||
|
owlA2Dg2tqVXV694SYqOmCMYY2uRBkIjEGJ9GK4xirPTGsS/OB34ga1oeo85qfkR
|
||||||
|
z0MzE5UQA3NPfp5Lo1MCxjsACkiiKwi10lW57y0CgYBYj2mPU/JHC7gHBTQAktuA
|
||||||
|
Uwh5QkKc62+gm09EZTdyrk4KA+uBY1EFsARn1zuRVOjbFpNkY5ll5+ObGl+P8UiR
|
||||||
|
1TBTneajm5hJj26So7WFjpJ9jzb472RyvPfsbe0GEHx1zj43NF0bLra63YQQeey2
|
||||||
|
RFMEZkZfyPbajxH0yObnIQKBgQDAINzIB6ltce9rR8s79GufCIY+jbj8mH64pDgb
|
||||||
|
h7XVnPa01ehJ4FxgqBHGkwlmmnhlBxaH4THSh5kYWej3nFzwhWtnDse88+Ol1++X
|
||||||
|
8rW9XpECCxE/iLDpsVguBKa5UH6nvqQWrR2qx4uwrx/zZJhFTyaSMdlzCA6jwz3h
|
||||||
|
io6rcQKBgBknilfMBkHRfaMhcVHWc2aiUsMBSogjY0Wf84mvLW0rDLfwPe5JX3qq
|
||||||
|
VwyXqcFfJ5oZMFmT7+ohcQybhDSdaE4TMkluFSFrYO2HRHzHg0i+K4NjtYhQSxmL
|
||||||
|
25X1Ravg9zXcR6O22jsXVPpRrOm2qA0q5pC9WcVqwYZZjhmzu6A4
|
||||||
|
-----END RSA PRIVATE KEY-----
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
sw!ft!sC00l
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIGJTCCBQ2gAwIBAgISA8I9tomI5N82h2iMz35TyPcSMA0GCSqGSIb3DQEBCwUA
|
||||||
|
MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD
|
||||||
|
ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xNzEwMTYxNTAzNThaFw0x
|
||||||
|
ODAxMTQxNTAzNThaMBoxGDAWBgNVBAMTD3NzbC5nZWxhcmVoLnh5ejCCAiIwDQYJ
|
||||||
|
KoZIhvcNAQEBBQADggIPADCCAgoCggIBAKlEE4VdwjkBI/mACJwnAfAGYGk1dimU
|
||||||
|
js+x58JnRvVZfMQQ5f7EGC4ezX2ra9gCngBv+U48P378uMCSxaGAmnyNO2vxWciz
|
||||||
|
v5K5+id2+RMlHkXHlrCKj1TarqUe2W02GdsLiBBXKTBjiC+1dXRztZVXudcbagbz
|
||||||
|
fbjKQIoEPbR+VYBr8WJsL/FpZcXC2Gx2uBO07mtK+WQGo2UpZOE65m0yg74//Eyk
|
||||||
|
L+hyt6PQEvznazSXjpVK+lBS0YwPOK2CQRT7kLUaVCIFf+O6Lg8I1EgEGldc91xh
|
||||||
|
op9H1nBUMIw3xc0FMo5d15f79+yOh91mDWY1F82RidLo8ZaPDgDsy/iL7NrT7plQ
|
||||||
|
qACVSKWqRqvXYIDbF19z9urVqyvnmFlqXtsuf4Iv5JCnnqHQ4852rm9w5sc6mVny
|
||||||
|
ikhmxPABHu3cpBtWDYhyow4FQXi0HAefi8vNw4E1O5lzCcJUgPvj/svsCRn/YgSH
|
||||||
|
Zq2bEGZCsczAiLHGGaIqpsNcnoZOTYN1OU0nqLHY0WGgyx2KzsDWS03+p6Ecm5QF
|
||||||
|
h2DOzO/moF/dsr707wEpgsKrQZ9scvck9BDkc3wCzoH+qAjcFlWdnQk+8/5aldgx
|
||||||
|
BYeOUgE3V4gGCYYggENVLwinH8/c+umpYkhq//SGTff/o5l0u1hp/Gf/WJ5TaZKk
|
||||||
|
nRrATni5hkRtAgMBAAGjggIzMIICLzAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYw
|
||||||
|
FAYIKwYBBQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB/wQCMAAwHQYDVR0OBBYEFFcp
|
||||||
|
eRLK7uObBVrJyJk3t3tV1qA7MB8GA1UdIwQYMBaAFKhKamMEfd265tE5t6ZFZe/z
|
||||||
|
qOyhMG8GCCsGAQUFBwEBBGMwYTAuBggrBgEFBQcwAYYiaHR0cDovL29jc3AuaW50
|
||||||
|
LXgzLmxldHNlbmNyeXB0Lm9yZzAvBggrBgEFBQcwAoYjaHR0cDovL2NlcnQuaW50
|
||||||
|
LXgzLmxldHNlbmNyeXB0Lm9yZy8wPgYDVR0RBDcwNYIPc3NsLmdlbGFyZWgueHl6
|
||||||
|
ghBzc2wxLmdlbGFyZWgueHl6ghBzc2wyLmdlbGFyZWgueHl6MIH+BgNVHSAEgfYw
|
||||||
|
gfMwCAYGZ4EMAQIBMIHmBgsrBgEEAYLfEwEBATCB1jAmBggrBgEFBQcCARYaaHR0
|
||||||
|
cDovL2Nwcy5sZXRzZW5jcnlwdC5vcmcwgasGCCsGAQUFBwICMIGeDIGbVGhpcyBD
|
||||||
|
ZXJ0aWZpY2F0ZSBtYXkgb25seSBiZSByZWxpZWQgdXBvbiBieSBSZWx5aW5nIFBh
|
||||||
|
cnRpZXMgYW5kIG9ubHkgaW4gYWNjb3JkYW5jZSB3aXRoIHRoZSBDZXJ0aWZpY2F0
|
||||||
|
ZSBQb2xpY3kgZm91bmQgYXQgaHR0cHM6Ly9sZXRzZW5jcnlwdC5vcmcvcmVwb3Np
|
||||||
|
dG9yeS8wDQYJKoZIhvcNAQELBQADggEBAB2pZwz/o9x2+/30zrubOTeuVXLVbjDq
|
||||||
|
uqbvmxbUNbCcn2putCiLQ804O1A0bLSLHgj0gKx9eE6bByTBa9k8LeLZB5UCQ9Ns
|
||||||
|
OOZSbzj7d4n+KRg0YrUApH/I3H2C43LK0oRvjdIX/KBEEdsXeML6FwuJnWb84ZEN
|
||||||
|
ZfPVBhrw2aH17EIfm7TcXo8CLjxhuJDA2OOwZVUg7ZMkIvP3EIhsBuyBuIMGHT/7
|
||||||
|
qaeVT7qeSQ3KhOguBnSkmxBwfn/aVZ83p9AvsZX5xuzhg5RCKx3u/qsQMq2Urf8x
|
||||||
|
uDKtmm7AdTHq6DeULVxmHj2386u6Kel1IlZtZNllQj/WW4uDM2EZQ78=
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
|
||||||
Binary file not shown.
@@ -0,0 +1,28 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/
|
||||||
|
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
|
||||||
|
DkRTVCBSb290IENBIFgzMB4XDTE2MDMxNzE2NDA0NloXDTIxMDMxNzE2NDA0Nlow
|
||||||
|
SjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUxldCdzIEVuY3J5cHQxIzAhBgNVBAMT
|
||||||
|
GkxldCdzIEVuY3J5cHQgQXV0aG9yaXR5IFgzMIIBIjANBgkqhkiG9w0BAQEFAAOC
|
||||||
|
AQ8AMIIBCgKCAQEAnNMM8FrlLke3cl03g7NoYzDq1zUmGSXhvb418XCSL7e4S0EF
|
||||||
|
q6meNQhY7LEqxGiHC6PjdeTm86dicbp5gWAf15Gan/PQeGdxyGkOlZHP/uaZ6WA8
|
||||||
|
SMx+yk13EiSdRxta67nsHjcAHJyse6cF6s5K671B5TaYucv9bTyWaN8jKkKQDIZ0
|
||||||
|
Z8h/pZq4UmEUEz9l6YKHy9v6Dlb2honzhT+Xhq+w3Brvaw2VFn3EK6BlspkENnWA
|
||||||
|
a6xK8xuQSXgvopZPKiAlKQTGdMDQMc2PMTiVFrqoM7hD8bEfwzB/onkxEz0tNvjj
|
||||||
|
/PIzark5McWvxI0NHWQWM6r6hCm21AvA2H3DkwIDAQABo4IBfTCCAXkwEgYDVR0T
|
||||||
|
AQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYwfwYIKwYBBQUHAQEEczBxMDIG
|
||||||
|
CCsGAQUFBzABhiZodHRwOi8vaXNyZy50cnVzdGlkLm9jc3AuaWRlbnRydXN0LmNv
|
||||||
|
bTA7BggrBgEFBQcwAoYvaHR0cDovL2FwcHMuaWRlbnRydXN0LmNvbS9yb290cy9k
|
||||||
|
c3Ryb290Y2F4My5wN2MwHwYDVR0jBBgwFoAUxKexpHsscfrb4UuQdf/EFWCFiRAw
|
||||||
|
VAYDVR0gBE0wSzAIBgZngQwBAgEwPwYLKwYBBAGC3xMBAQEwMDAuBggrBgEFBQcC
|
||||||
|
ARYiaHR0cDovL2Nwcy5yb290LXgxLmxldHNlbmNyeXB0Lm9yZzA8BgNVHR8ENTAz
|
||||||
|
MDGgL6AthitodHRwOi8vY3JsLmlkZW50cnVzdC5jb20vRFNUUk9PVENBWDNDUkwu
|
||||||
|
Y3JsMB0GA1UdDgQWBBSoSmpjBH3duubRObemRWXv86jsoTANBgkqhkiG9w0BAQsF
|
||||||
|
AAOCAQEA3TPXEfNjWDjdGBX7CVW+dla5cEilaUcne8IkCJLxWh9KEik3JHRRHGJo
|
||||||
|
uM2VcGfl96S8TihRzZvoroed6ti6WqEBmtzw3Wodatg+VyOeph4EYpr/1wXKtx8/
|
||||||
|
wApIvJSwtmVi4MFU5aMqrSDE6ea73Mj2tcMyo5jMd6jmeWUHK8so/joWUoHOUgwu
|
||||||
|
X4Po1QYz+3dszkDqMp4fklxBwXRsW10KXzPMTZ+sOPAveyxindmjkW8lGy+QsRlG
|
||||||
|
PfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6
|
||||||
|
KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg==
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
-----BEGIN CERTIFICATE REQUEST-----
|
||||||
|
MIIFAzCCAusCAQAwbTEYMBYGA1UEAxMPc3NsLmdlbGFyZWgueHl6MRAwDgYDVQQK
|
||||||
|
DAdQcml2YXRlMREwDwYDVQQLDAhJVCBEZXB0LjETMBEGA1UEBwwKV2FzaGluZ3Rv
|
||||||
|
bjEKMAgGA1UECAwBLTELMAkGA1UEBgwCVVMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
|
||||||
|
DwAwggIKAoICAQCpRBOFXcI5ASP5gAicJwHwBmBpNXYplI7PsefCZ0b1WXzEEOX+
|
||||||
|
xBguHs19q2vYAp4Ab/lOPD9+/LjAksWhgJp8jTtr8VnIs7+SufondvkTJR5Fx5aw
|
||||||
|
io9U2q6lHtltNhnbC4gQVykwY4gvtXV0c7WVV7nXG2oG8324ykCKBD20flWAa/Fi
|
||||||
|
bC/xaWXFwthsdrgTtO5rSvlkBqNlKWThOuZtMoO+P/xMpC/ocrej0BL852s0l46V
|
||||||
|
SvpQUtGMDzitgkEU+5C1GlQiBX/jui4PCNRIBBpXXPdcYaKfR9ZwVDCMN8XNBTKO
|
||||||
|
XdeX+/fsjofdZg1mNRfNkYnS6PGWjw4A7Mv4i+za0+6ZUKgAlUilqkar12CA2xdf
|
||||||
|
c/bq1asr55hZal7bLn+CL+SQp56h0OPOdq5vcObHOplZ8opIZsTwAR7t3KQbVg2I
|
||||||
|
cqMOBUF4tBwHn4vLzcOBNTuZcwnCVID74/7L7AkZ/2IEh2atmxBmQrHMwIixxhmi
|
||||||
|
KqbDXJ6GTk2DdTlNJ6ix2NFhoMsdis7A1ktN/qehHJuUBYdgzszv5qBf3bK+9O8B
|
||||||
|
KYLCq0GfbHL3JPQQ5HN8As6B/qgI3BZVnZ0JPvP+WpXYMQWHjlIBN1eIBgmGIIBD
|
||||||
|
VS8Ipx/P3PrpqWJIav/0hk33/6OZdLtYafxn/1ieU2mSpJ0awE54uYZEbQIDAQAB
|
||||||
|
oFEwTwYJKoZIhvcNAQkOMUIwQDA+BgNVHREENzA1gg9zc2wuZ2VsYXJlaC54eXqC
|
||||||
|
EHNzbDEuZ2VsYXJlaC54eXqCEHNzbDIuZ2VsYXJlaC54eXowDQYJKoZIhvcNAQEL
|
||||||
|
BQADggIBAA3xerDVnLk8KAs7ooHWKiQNdM5dUvWgPbMehUxtaZCIA6IraR1qZDfj
|
||||||
|
4+zvumBOPRdbTYbts1xfbdt+T4B+liu+Zkz+zfYJ+pGglDfe9G0oF8fldIfwUzT5
|
||||||
|
v6+VF5wiR6mT3F8pUpLqJd6PMHFlb+WTPKZjYVoBDKQ0G2HLSAfHsocaahPvz9Zg
|
||||||
|
Cz+4FraCk7wlxAG0nzwycQ1NhDpEjQ7Q0UQd23SNWCGc07ZYCfwPLJKCCR0MDhuL
|
||||||
|
J20rZ+PY+7zWXBLULG49mid1uSpp7XmOcIIj0oFvyv0PmaUOWgvm6zr6nBoKALKW
|
||||||
|
Qo0dQhY0ODP19uu/NmcS5T97BW6yWti8c9tWJmeMu9WrO8wMyY8DXID0dgdGo9a7
|
||||||
|
UJo227ZoyqjUHSsrqtP9W8rjok7XRLgxUyRPw1boqAyBnY474v6LUc/VEQNv8mBk
|
||||||
|
u6HJkWD2dWlAaClpzD37PPPOvuQ8BOiaSI6xrL3+VdfD0Q6GE6jaUuhe+KPwv69N
|
||||||
|
v+/ErQQXHP08WeaXMHV9yEOtMmVyRvY+9rVIS9HI6cuXLTcMN8cI8TW5f+0IJ/ll
|
||||||
|
RCY+5Pts++6ajIFC6JwaXBc4mjH8fngHrZByErN3wx0vrPXxs+oXba+ohtnAupNf
|
||||||
|
wA9qIxSKLJtV/xDxHEqyplX0ke7szhbHzOE1ENgPMeNH0/lDmH1F
|
||||||
|
-----END CERTIFICATE REQUEST-----
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIJKgIBAAKCAgEAqUQThV3COQEj+YAInCcB8AZgaTV2KZSOz7HnwmdG9Vl8xBDl
|
||||||
|
/sQYLh7Nfatr2AKeAG/5Tjw/fvy4wJLFoYCafI07a/FZyLO/krn6J3b5EyUeRceW
|
||||||
|
sIqPVNqupR7ZbTYZ2wuIEFcpMGOIL7V1dHO1lVe51xtqBvN9uMpAigQ9tH5VgGvx
|
||||||
|
Ymwv8WllxcLYbHa4E7Tua0r5ZAajZSlk4TrmbTKDvj/8TKQv6HK3o9AS/OdrNJeO
|
||||||
|
lUr6UFLRjA84rYJBFPuQtRpUIgV/47ouDwjUSAQaV1z3XGGin0fWcFQwjDfFzQUy
|
||||||
|
jl3Xl/v37I6H3WYNZjUXzZGJ0ujxlo8OAOzL+Ivs2tPumVCoAJVIpapGq9dggNsX
|
||||||
|
X3P26tWrK+eYWWpe2y5/gi/kkKeeodDjznaub3DmxzqZWfKKSGbE8AEe7dykG1YN
|
||||||
|
iHKjDgVBeLQcB5+Ly83DgTU7mXMJwlSA++P+y+wJGf9iBIdmrZsQZkKxzMCIscYZ
|
||||||
|
oiqmw1yehk5Ng3U5TSeosdjRYaDLHYrOwNZLTf6noRyblAWHYM7M7+agX92yvvTv
|
||||||
|
ASmCwqtBn2xy9yT0EORzfALOgf6oCNwWVZ2dCT7z/lqV2DEFh45SATdXiAYJhiCA
|
||||||
|
Q1UvCKcfz9z66aliSGr/9IZN9/+jmXS7WGn8Z/9YnlNpkqSdGsBOeLmGRG0CAwEA
|
||||||
|
AQKCAgAfdzdFyJsta6fbXtC67olurFDJ3hVcP3CY7ZKO0hIf1AXckOOgi6WPFUzP
|
||||||
|
+sjue/YRUL+AqrSHD8XsjpxMnJKbasnMFC7Dn56SUR5OrdA5neHVyPebU/a3KHvk
|
||||||
|
2CpFIhSGYstldj6C703GyK3P+x6bZ5Z1hXQdXLBXZMnAnm82GXIdkHNr/36eGyC/
|
||||||
|
Naxz5VHs3+qeaW6ZCJ7hVGObdw6U6BoTiOOG/9KkHIdE3Y5aE08blLz9xdVojyzD
|
||||||
|
I6U+pAMjOmy5Le7L8EfI9rhPNS35QUIAUZjuRHwtrfYQJaZsuoV7ymaOjqVgbIe3
|
||||||
|
IvvgzXLaOC53mYGMgp8+hNNumpaEDQtUE2HonEJYi8rjhMlhlvh8OWbHCI9yjMRg
|
||||||
|
eMtk3fZ4dtHGFu0XUpZegPFPEMsBmOVELWu9GPs6RNa4U7LsTFBTipUasyKREgdW
|
||||||
|
CbLBu+6+lFe67deUh2150j9PJ9r8SyFUp9UwMMtZirTI6OMxoEylg6gd5Gtvckhz
|
||||||
|
M+VSGX8w/fKRzW7Ipf94TIQlaAkjHI68AB7Qw30uaT9YfbEOP8cMSy9ZBKe+JQ/A
|
||||||
|
EtYsrOjHtARJ7pOWbifnu4zNKg8C4LIDt8sv+en/1/MFXO8+VRVUBmlNzvY8rD1Y
|
||||||
|
5mBftmWdAmFnHCtQH+3VwE331UjpZlYaNTBDe4TwbJeIcTmmQQKCAQEA5JG0/FHa
|
||||||
|
lAvr5Yo8/TI0NqX6bwjn52V6HX5x2Z/wpgQp+WzpSKNCQEWBDsS3X0SfGMJDHFcx
|
||||||
|
X8ysmnLAXcUbBmgnVP2see5cqGQyhHUL/GtfThGAdcs8defkZJspoiFwA1UioJO5
|
||||||
|
JahxBwyxdq6i61ijr1/PjVNWc4wRCsvV/pymmqNKACgiFsW6KB3gq9mcZewK9iZ3
|
||||||
|
nB+H2gQ9PXrC/re9efHO/rUPMuFo3caFZZTTOUbh/Ilno4B//OzXR/mT0ti1YQly
|
||||||
|
5AUkMRwoMUmUGMGZ2IHy2AKEnkk6YvkbTSiTLgsVjgW/MqSjuoeInTwCqRex7Te4
|
||||||
|
3L98/bFGzpG1HQKCAQEAvZRnyWhsUhimOAY0EQ+14bLqEU1D7zFIdEibGVdU4Z49
|
||||||
|
W2/q3CKvbU0gsE5z/L8Y0d+HfKEKsuIvz78SRjds8L1E/V8CReFsyQJW6WO2LNXG
|
||||||
|
eWKMKAJlHuD+s7bOmPssVVj2x05jdoN03tsDKS5rC+DnRYeBnp8uAPdHN5otwDbF
|
||||||
|
FGU1alTGUgTrcboPVf4OhaKh66VxbGliLq35mXW3E90aWtNrByuyJohobfjrpDwd
|
||||||
|
kLK6XbxUdkvIwylk+ZPOL9gI/p1Q38bsSP+w49UxASUvt5CfXaHxhc0qzMrFf2Tm
|
||||||
|
5EYDLx3qsNbqgOf5KzsYwsDsKXUkENsIaRQ7dnU7kQKCAQEA4ndT4WSgs2sUcbwE
|
||||||
|
LcKeZT8S4Qzr6SNsWOi9mSiVYYhiplW41lWcAN5cvus93NC66ecgY2Yo74h1xBnK
|
||||||
|
a54t5q0vu1AUokL/34BXZVIrbBBev5UruIqD/zah3uS13YRP3Z1uz7dODPfV9Wwo
|
||||||
|
MTVbCuAqXksJ9DcMQzQWdqH8B2fi0vjTC1C4ZePHTJQ91UepZHr5aWY3wKKlEeh9
|
||||||
|
XPrTVVlsDPT/aPKwenNIWeSmqz1IA0ouAu+JlkBtj4aCzzeDtbcuD1UzVqWZdGc3
|
||||||
|
k44ZhGXeLtyiZlAoYkSf6wxydoKrQUWON8eN53mlF93OCCw7Xpqxmh5Jtb6s8xfA
|
||||||
|
1k8cKQKCAQEAqONc0oDEfx6WdbKRD+H/FmJdQ6yhqKUu9uj3w0uZwqVF4/+AKzx7
|
||||||
|
K9RaGrbJfZCAe/e2q8CL13DJRzng/czCsHTs0Qui6r44O5pp8uFxmd+YQOsaEUqQ
|
||||||
|
60FlppRk2MRqal4m+sdKtHnH1AEof7dqhdqGLdraDoWgZhvkxhQETgh86f5/54o+
|
||||||
|
YzMezOIEZ4c9SK/psBRjR0FaxlsW0S+dOYTvxZoy7uBuhQVggxgOVPF5JT8T6A2u
|
||||||
|
8PPylmp6Gh0iwlyjJrDfK3v7Y8zluRJj5bFLIS0lzDRJBfoQ9wBtkWBCkXoNvBva
|
||||||
|
yE+t+ciuoWS0WkukGArTZnC6vWHY1175AQKCAQEA2K5DSq6hEcmQGKHBogWW4Emo
|
||||||
|
kz+IyJVwmDPDGhiVWApMODhMVGKbRM4dVVf8CFNYZKyTpbfUdivs0xcALigopjTW
|
||||||
|
bdE/gH7B81yA7hW7UD3oFOMSlu+6xi4GcB43rML1K/6KUAd7a3pVNl3YxywF6dKa
|
||||||
|
e7Tl3Ye0oq1L7haNTgGOd/1C7u72/oKsnoZH7dSGZA/AvhkMCYXWSTGq5iMATUuQ
|
||||||
|
yDh59Twmn9a+bN6bZy/Kt/Lwg+3Xptb9uEkGlwaEvtVzXGa9FfHD4WKt6TavbHY/
|
||||||
|
tI/psRiolGcG5/i8lIQN1USbHdM1v1BPWlr8MDojqXn4n5gUIwtoEEWq4laPvw==
|
||||||
|
-----END RSA PRIVATE KEY-----
|
||||||
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIJJwIBAAKCAgEAjKfEit347Xx0mvjc3cBOhk+fa4Qx/EH/SCz5eMxdBAJe9VfU
|
||||||
|
MKeKjlFHVVtO97Nmv28OPbE5w4LgVtfwjChav76L4uD0GRMsjRGQFXiHV+UtxJ7G
|
||||||
|
MCUUuCgm4IQDQvCJ0oKcJ4YP7UziJOGk8PkIdMjHdzLYaRSZookYXJaSxx/h/OEj
|
||||||
|
W+up7u++Nwh/RUCegLDtdOuFENzovutIzie8sa4lbD3e4QBdayZez2u8pfVMfRiO
|
||||||
|
pYkymCyNNkRwLlOBPZZBCQHfQWjCcGKOJdRq0h5WZ6Rxxza8HA03YoEqASnHJ/ok
|
||||||
|
RQ1Gy0M9osFswyYmaPp8lWMi14aXlMFHbbL+G4p23BhBeiTnDR4wLM/UjATHNVxk
|
||||||
|
KiBnqr2sUHc8dnFqNiUgoJWc2aRL1EToHWOdJ51s/ZLFraPPViOPpCHQG7SetY7a
|
||||||
|
dJFdgQoee4fk9o6Zo9q7izRm70QHHuKGFIjNxs7ZSL6bjYMwKHLK5G75Q3WCqmNd
|
||||||
|
irfsQYjUL/TYNJnazfHV3702YKBcugg08R8q69TNakhfnDgRl5FIMd6Bro3CgA8L
|
||||||
|
bGL4jjoAhx0PohvIlJhghGwQ8xQEfWLmL0pRWUEV4gBIfGxLGQpLqt97choOGdYY
|
||||||
|
GZt+nuzR7KZH175BKNhMI9xcqD6/fb0jNT+GBC2s7DcZSLDODeU0Hf1BXR0CAwEA
|
||||||
|
AQKCAgA7kvtuDeJXRDVnRizWR5N609KkCVPakmF7woDPp09mWVK6+75F9VB8QvTB
|
||||||
|
tHDX/UZxoqoXey8KHi7C2adq1dTKDfzV1Y3N6Q8fmOa8EVbR5aHi+5TZ43rJHUiK
|
||||||
|
I5/2BEd7wBI/s0qfqcbG9EOWRQRN4pSJaiG7MBx6eTK2VJhKeriPERSW5FQPfb/F
|
||||||
|
M3YkcOAxhb6tnOu5Xre91Y36s136q9Xx6Kq0BiGLNq9Fj05RxHnnKjWQ63Fgfs44
|
||||||
|
w/f3xyqgWTmmhQJ4g9SHIVcvsq6j3HGgaEhApnA6OWbR8/9EitttlUczcBIiGZLL
|
||||||
|
kr1sUoZGRIHsDBc/ziP5v3tvfTae9qhqPN0Nnkpl/VLkUieS0iee5f8nCF7NgqMH
|
||||||
|
lPTKzPrsV+6Jq0BwHxh3trKRdfHxocIEQlzmn9MokX7iTWzcirmo3E/rpaCcSlys
|
||||||
|
H5sQtMiN1wtvPCIC4yCPRJf8dkiOK/CjMuEw+bsrO486agVLUOfbDfWWesHQ2Oqm
|
||||||
|
VQSfdLN/WeIzq9rFLp7SywBA0aeNEd4xP55iua+PiTH9nHpcJVk8PFiPwL9Q+Y5p
|
||||||
|
ZFV7CoUGzMJvqbusQca9GX1/kycfDrxrqM7Mb24fmLpmu9LEfQ6cwf04f39KTL1D
|
||||||
|
Js2D+6vwSKmE/21z8JrPUyaizGS3VqRtFGKSYVmk+0f8hZQmyQKCAQEAyBIkBPMe
|
||||||
|
booWLOdo+PpRkwjetbq/zOv3izfd0EG6GL1dy3TO0bzVeEmQ1nRHyOr+23leNxto
|
||||||
|
25uOoZ2yceRiK4i01VKRy4Gc6htegC0/UNpywTxIQEfWQeDZmvHDWpEpZ20GY3ER
|
||||||
|
xBd4xwwZNvyh/j5Jq7hPkDFprCQJ8vouERhQh071HlnE0f8zVfK+t4UdpN6F/5wc
|
||||||
|
kZP8j7C2FRWQn0XjsQeXO2PGZOlNphNYGda4nlaB9b21oYCiFni+TI44fkbEQQCX
|
||||||
|
LervYGy08fTT+Xe3MSGTwo/RwoR4YEubBeGZOCQUjdCl2FT1SVce930RfEQxajH6
|
||||||
|
8Ud7IPI0nvDAQwKCAQEAs/meS7fEisbyoQC9cpXvd6RSNZL+uLrk5Ljb3QnmXdLs
|
||||||
|
D2vfsXKIIfghKwhtStWBBTSyXxqI/EZeTxjPUjC6cW/7ZPPh6P6bCVWPBLystd5N
|
||||||
|
kGtpeJU6tzGOLr2bJKLL9HchntZpbASqE0YIpd3/3cGCjCVYz9FQItI0ghuEaPhP
|
||||||
|
9F8iaqO22jBJIMplvRBNCi7LOBL+dcGHFBi4nVH+K/hYN2Itt1Bxpg+wqzbNhXn0
|
||||||
|
KQahWNZnSTUNCv9CPssYJf5Lkm++c5D1h55MBxOznhP2JQJg6eLG7jZcpQIrVX1Z
|
||||||
|
r76TQSuHWh/xCV6BRaj2RvucYHx7Gv6vWRnLlWLHHwKCAQBr2VuRT30YGVfa3OO5
|
||||||
|
UzamDCIB1KmPzaOjaHopyUSIEYx+IHlclm58aSuqbwRDSmoX5VTkX+Imf7Rjap7G
|
||||||
|
xlYlIYxZciklirkLebV3Yuy+qQMzJ0vLWu4klRC4dZrZN2caWasX79uj2QNCSUNO
|
||||||
|
YODyLKGJ79Dz6a8NHGBAmpw6muDOD8ISmlF+4hLKQhCM3TUdqtaQ85Zy41NCIgAF
|
||||||
|
XZqYQRR8WZssaJyJyToSTFsxko3yzK9ByQIgDTdS5cOvgPrzFzKz152nIv3m/LKN
|
||||||
|
u2yJDf+yfGcqelyYftBlGFx4zyPJH6n0yISeGS4gWtZWkxTZ5+i7VjXv2piFKgsz
|
||||||
|
opQBAoIBAEmXcmDnvdg5TZEEKnMmWAsGCA+cEcgbs+jKpiyWFbqbuqb7pzZ57Kxn
|
||||||
|
N7jO81G8R8uHJsC4qvbtFzckn/Gtty8XaSZ4ixGoumBwudBoDf837WN2aGREMQQj
|
||||||
|
oU3/febXIqrN49N9PRJMPfcvle2s/ykALY983fnsTuZOKeZhthzuHFOCayJL20MQ
|
||||||
|
p3ZfDIbomXfmdnZxXdds0P0otqStmE8Gd5v960+f9zi+BbGc8SD5Ixt7eJJI6WcH
|
||||||
|
6FNs2PuwNCmk9+XjB29eAOf5lID4T2P+KZIsjNBWSJ2zYOKgJnQIk5nHRZNKZ0g0
|
||||||
|
82yvVhDT7BBOZj0V6Yi6R50ZbSOihmUCggEAIfAL588EVaF3lxBnf5L/kCEaeXMO
|
||||||
|
zAVg4DUGgKWBQTyaKplOP01PcmfgPzDBZk0HMBfF+w6R849ufeuO9mIAIP4N4+Q/
|
||||||
|
J7gVKLz6vKZLoPpGXmk/fxCz6d/iH5a4R4KS2IGz/B40DC0vg5wIOgM5VeC5XYxo
|
||||||
|
o8tlDHsL0nmeK6klIZswQgnln1hkgYR8DWdhdtCpOyGoxk+ZObZHYdCShgDzrJHe
|
||||||
|
lNADdNopXdsbmVIOGklgbQDNqAdoZIEMSERevRD4tzi8tVTyNRHH4tzWzvf2Equ7
|
||||||
|
SD9y196c5G8PHQcOX8TG7Q07jojsAcyudjfJ6yITMBVuxiCTFsgn2doyfA==
|
||||||
|
-----END RSA PRIVATE KEY-----
|
||||||
|
|
||||||
+27
-12
@@ -1,20 +1,35 @@
|
|||||||
// 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
|
import PackageDescription
|
||||||
|
|
||||||
let package = Package(
|
let package = Package(
|
||||||
name: "SwiftServerHTTP",
|
name: "SwiftServerHttp",
|
||||||
targets: [
|
products: [
|
||||||
Target(name: "HTTP"),
|
// Products define the executables and libraries produced by a package, and make them visible to other packages.
|
||||||
Target(name: "BlueSocketHTTP", dependencies: ["HTTP"]),
|
.library(
|
||||||
|
name: "HTTP",
|
||||||
|
targets: ["HTTP"]),
|
||||||
],
|
],
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.Package(url: "https://github.com/IBM-Swift/CHTTPParser.git", majorVersion: 0, minor: 4),
|
// Dependencies declare other packages that this package depends on.
|
||||||
.Package(url: "https://github.com/IBM-Swift/BlueSocket.git", majorVersion: 0, minor: 12),
|
// .package(url: /* package url */, from: "1.0.0"),
|
||||||
|
// ServerSecurity: common headers, definitions and protocols
|
||||||
|
.package(url: "https://github.com/swift-server/security.git", from: "0.0.0"),
|
||||||
|
// TLSService: implementation of ServerSecurity using OpenSSL and SecureTransport
|
||||||
|
.package(url: "https://github.com/swift-server/TLSService.git", from: "0.20.3"),
|
||||||
|
],
|
||||||
|
targets: [
|
||||||
|
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||||
|
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
|
||||||
|
.target(
|
||||||
|
name: "CHTTPParser",
|
||||||
|
dependencies: []),
|
||||||
|
.target(
|
||||||
|
name: "HTTP",
|
||||||
|
dependencies: ["CHTTPParser", "ServerSecurity", "TLSService"]),
|
||||||
|
.testTarget(
|
||||||
|
name: "HTTPTests",
|
||||||
|
dependencies: ["HTTP"]),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
#if os(Linux)
|
|
||||||
package.dependencies.append(
|
|
||||||
.Package(url: "https://github.com/IBM-Swift/BlueSignals.git", majorVersion: 0, minor: 9))
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -1,3 +1,83 @@
|
|||||||
# 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.
|
:warning: This project is unmaintained experimental legacy code. It has been obsoleted by [SwiftNIO](https://github.com/apple/swift-nio) which contains the recommended HTTP API of the [Swift Server Work Group](https://swift.org/server/).
|
||||||
|
|
||||||
|
It remains here for historical interest only.
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
|
||||||
|
### Hello World
|
||||||
|
The following code implements a very simple "Hello World!" server:
|
||||||
|
|
||||||
|
```swift
|
||||||
|
import Foundation
|
||||||
|
import HTTP
|
||||||
|
|
||||||
|
func hello(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||||
|
response.writeHeader(status: .ok)
|
||||||
|
response.writeBody("Hello, World!")
|
||||||
|
response.done()
|
||||||
|
return .discardBody
|
||||||
|
}
|
||||||
|
|
||||||
|
let server = HTTPServer()
|
||||||
|
try! server.start(port: 8080, handler: hello)
|
||||||
|
|
||||||
|
RunLoop.current.run()
|
||||||
|
```
|
||||||
|
|
||||||
|
The `hello()` function receives a `HTTPRequest` that describes the request and a `HTTPResponseWriter` used to write a response.
|
||||||
|
|
||||||
|
Data that is received as part of the request body is made available to the closure that is returned by the `hello()` function. In the "Hello World!" example the request body is not used, so `.discardBody` is returned.
|
||||||
|
|
||||||
|
### Echo Server
|
||||||
|
The following code implements a very simple Echo server that responds with the contents of the incoming request:
|
||||||
|
|
||||||
|
```swift
|
||||||
|
import Foundation
|
||||||
|
import HTTP
|
||||||
|
|
||||||
|
func echo(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||||
|
response.writeHeader(status: .ok)
|
||||||
|
return .processBody { (chunk, stop) in
|
||||||
|
switch chunk {
|
||||||
|
case .chunk(let data, let finishedProcessing):
|
||||||
|
response.writeBody(data) { _ in
|
||||||
|
finishedProcessing()
|
||||||
|
}
|
||||||
|
case .end:
|
||||||
|
response.done()
|
||||||
|
default:
|
||||||
|
stop = true
|
||||||
|
response.abort()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let server = HTTPServer()
|
||||||
|
try! server.start(port: 8080, handler: echo)
|
||||||
|
|
||||||
|
RunLoop.current.run()
|
||||||
|
```
|
||||||
|
As the Echo server needs to process the request body data and return it in the reponse, the `echo()` function returns a `.processBody` closure. This closure is called with `.chunk` when data is available for processing from the request, and `.end` when no more data is available.
|
||||||
|
|
||||||
|
Once any data chunk has been processed, `finishedProcessing()` should be called to signify that it has been handled.
|
||||||
|
|
||||||
|
When the response is complete, `response.done()` should be called.
|
||||||
|
|
||||||
|
## API Documentation
|
||||||
|
Full Jazzy documentation of the API is available here:
|
||||||
|
<https://swift-server.github.io/http/>
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
### Feedback
|
||||||
|
We are actively seeking feedback on this prototype and your comments are extremely valuable. If you have any comments on the API design, the implementation, or any other aspects of this project, please email the [`swift-server-dev`](https://lists.swift.org/mailman/listinfo/swift-server-dev) mailing list.
|
||||||
|
|
||||||
|
### Writing Code
|
||||||
|
We also welcome code contributions. If you are developing on macOS, you may want to work within Xcode. This project uses the [Swift Package Manager](https://swift.org/package-manager/). To work on this project within Xcode you can run the Swift Package Manager command `swift package generate-xcodeproj` to generate an `.xcodeproj` to work on within Xcode.
|
||||||
|
|
||||||
|
## Acknowledgements
|
||||||
|
This project is based on an inital proposal from @weissi on the swift-server-dev mailing list:
|
||||||
|
<https://lists.swift.org/pipermail/swift-server-dev/Week-of-Mon-20170403/000422.html>
|
||||||
|
|||||||
@@ -1,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,68 @@
|
|||||||
|
# Authors ordered by first contribution.
|
||||||
|
Ryan Dahl <ry@tinyclouds.org>
|
||||||
|
Jeremy Hinegardner <jeremy@hinegardner.org>
|
||||||
|
Sergey Shepelev <temotor@gmail.com>
|
||||||
|
Joe Damato <ice799@gmail.com>
|
||||||
|
tomika <tomika_nospam@freemail.hu>
|
||||||
|
Phoenix Sol <phoenix@burninglabs.com>
|
||||||
|
Cliff Frey <cliff@meraki.com>
|
||||||
|
Ewen Cheslack-Postava <ewencp@cs.stanford.edu>
|
||||||
|
Santiago Gala <sgala@apache.org>
|
||||||
|
Tim Becker <tim.becker@syngenio.de>
|
||||||
|
Jeff Terrace <jterrace@gmail.com>
|
||||||
|
Ben Noordhuis <info@bnoordhuis.nl>
|
||||||
|
Nathan Rajlich <nathan@tootallnate.net>
|
||||||
|
Mark Nottingham <mnot@mnot.net>
|
||||||
|
Aman Gupta <aman@tmm1.net>
|
||||||
|
Tim Becker <tim.becker@kuriositaet.de>
|
||||||
|
Sean Cunningham <sean.cunningham@mandiant.com>
|
||||||
|
Peter Griess <pg@std.in>
|
||||||
|
Salman Haq <salman.haq@asti-usa.com>
|
||||||
|
Cliff Frey <clifffrey@gmail.com>
|
||||||
|
Jon Kolb <jon@b0g.us>
|
||||||
|
Fouad Mardini <f.mardini@gmail.com>
|
||||||
|
Paul Querna <pquerna@apache.org>
|
||||||
|
Felix Geisendörfer <felix@debuggable.com>
|
||||||
|
koichik <koichik@improvement.jp>
|
||||||
|
Andre Caron <andre.l.caron@gmail.com>
|
||||||
|
Ivo Raisr <ivosh@ivosh.net>
|
||||||
|
James McLaughlin <jamie@lacewing-project.org>
|
||||||
|
David Gwynne <loki@animata.net>
|
||||||
|
Thomas LE ROUX <thomas@november-eleven.fr>
|
||||||
|
Randy Rizun <rrizun@ortivawireless.com>
|
||||||
|
Andre Louis Caron <andre.louis.caron@usherbrooke.ca>
|
||||||
|
Simon Zimmermann <simonz05@gmail.com>
|
||||||
|
Erik Dubbelboer <erik@dubbelboer.com>
|
||||||
|
Martell Malone <martellmalone@gmail.com>
|
||||||
|
Bertrand Paquet <bpaquet@octo.com>
|
||||||
|
BogDan Vatra <bogdan@kde.org>
|
||||||
|
Peter Faiman <peter@thepicard.org>
|
||||||
|
Corey Richardson <corey@octayn.net>
|
||||||
|
Tóth Tamás <tomika_nospam@freemail.hu>
|
||||||
|
Cam Swords <cam.swords@gmail.com>
|
||||||
|
Chris Dickinson <christopher.s.dickinson@gmail.com>
|
||||||
|
Uli Köhler <ukoehler@btronik.de>
|
||||||
|
Charlie Somerville <charlie@charliesomerville.com>
|
||||||
|
Patrik Stutz <patrik.stutz@gmail.com>
|
||||||
|
Fedor Indutny <fedor.indutny@gmail.com>
|
||||||
|
runner <runner.mei@gmail.com>
|
||||||
|
Alexis Campailla <alexis@janeasystems.com>
|
||||||
|
David Wragg <david@wragg.org>
|
||||||
|
Vinnie Falco <vinnie.falco@gmail.com>
|
||||||
|
Alex Butum <alexbutum@linux.com>
|
||||||
|
Rex Feng <rexfeng@gmail.com>
|
||||||
|
Alex Kocharin <alex@kocharin.ru>
|
||||||
|
Mark Koopman <markmontymark@yahoo.com>
|
||||||
|
Helge Heß <me@helgehess.eu>
|
||||||
|
Alexis La Goutte <alexis.lagoutte@gmail.com>
|
||||||
|
George Miroshnykov <george.miroshnykov@gmail.com>
|
||||||
|
Maciej Małecki <me@mmalecki.com>
|
||||||
|
Marc O'Morain <github.com@marcomorain.com>
|
||||||
|
Jeff Pinner <jpinner@twitter.com>
|
||||||
|
Timothy J Fontaine <tjfontaine@gmail.com>
|
||||||
|
Akagi201 <akagi201@gmail.com>
|
||||||
|
Romain Giraud <giraud.romain@gmail.com>
|
||||||
|
Jay Satiro <raysatiro@yahoo.com>
|
||||||
|
Arne Steen <Arne.Steen@gmx.de>
|
||||||
|
Kjell Schubert <kjell.schubert@gmail.com>
|
||||||
|
Olivier Mengué <dolmen@cpan.org>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
http_parser.c is based on src/http/ngx_http_parse.c from NGINX copyright
|
||||||
|
Igor Sysoev.
|
||||||
|
|
||||||
|
Additional changes are licensed under the same terms as NGINX and
|
||||||
|
copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to
|
||||||
|
deal in the Software without restriction, including without limitation the
|
||||||
|
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
IN THE SOFTWARE.
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,362 @@
|
|||||||
|
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#ifndef http_parser_h
|
||||||
|
#define http_parser_h
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Also update SONAME in the Makefile whenever you change these. */
|
||||||
|
#define HTTP_PARSER_VERSION_MAJOR 2
|
||||||
|
#define HTTP_PARSER_VERSION_MINOR 7
|
||||||
|
#define HTTP_PARSER_VERSION_PATCH 1
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#if defined(_WIN32) && !defined(__MINGW32__) && \
|
||||||
|
(!defined(_MSC_VER) || _MSC_VER<1600) && !defined(__WINE__)
|
||||||
|
#include <BaseTsd.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
typedef __int8 int8_t;
|
||||||
|
typedef unsigned __int8 uint8_t;
|
||||||
|
typedef __int16 int16_t;
|
||||||
|
typedef unsigned __int16 uint16_t;
|
||||||
|
typedef __int32 int32_t;
|
||||||
|
typedef unsigned __int32 uint32_t;
|
||||||
|
typedef __int64 int64_t;
|
||||||
|
typedef unsigned __int64 uint64_t;
|
||||||
|
#else
|
||||||
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Compile with -DHTTP_PARSER_STRICT=0 to make less checks, but run
|
||||||
|
* faster
|
||||||
|
*/
|
||||||
|
#ifndef HTTP_PARSER_STRICT
|
||||||
|
# define HTTP_PARSER_STRICT 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Maximium header size allowed. If the macro is not defined
|
||||||
|
* before including this header then the default is used. To
|
||||||
|
* change the maximum header size, define the macro in the build
|
||||||
|
* environment (e.g. -DHTTP_MAX_HEADER_SIZE=<value>). To remove
|
||||||
|
* the effective limit on the size of the header, define the macro
|
||||||
|
* to a very large number (e.g. -DHTTP_MAX_HEADER_SIZE=0x7fffffff)
|
||||||
|
*/
|
||||||
|
#ifndef HTTP_MAX_HEADER_SIZE
|
||||||
|
# define HTTP_MAX_HEADER_SIZE (80*1024)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct http_parser http_parser;
|
||||||
|
typedef struct http_parser_settings http_parser_settings;
|
||||||
|
|
||||||
|
|
||||||
|
/* Callbacks should return non-zero to indicate an error. The parser will
|
||||||
|
* then halt execution.
|
||||||
|
*
|
||||||
|
* The one exception is on_headers_complete. In a HTTP_RESPONSE parser
|
||||||
|
* returning '1' from on_headers_complete will tell the parser that it
|
||||||
|
* should not expect a body. This is used when receiving a response to a
|
||||||
|
* HEAD request which may contain 'Content-Length' or 'Transfer-Encoding:
|
||||||
|
* chunked' headers that indicate the presence of a body.
|
||||||
|
*
|
||||||
|
* Returning `2` from on_headers_complete will tell parser that it should not
|
||||||
|
* expect neither a body nor any futher responses on this connection. This is
|
||||||
|
* useful for handling responses to a CONNECT request which may not contain
|
||||||
|
* `Upgrade` or `Connection: upgrade` headers.
|
||||||
|
*
|
||||||
|
* http_data_cb does not return data chunks. It will be called arbitrarily
|
||||||
|
* many times for each string. E.G. you might get 10 callbacks for "on_url"
|
||||||
|
* each providing just a few characters more data.
|
||||||
|
*/
|
||||||
|
typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);
|
||||||
|
typedef int (*http_cb) (http_parser*);
|
||||||
|
|
||||||
|
|
||||||
|
/* Request Methods */
|
||||||
|
#define HTTP_METHOD_MAP(XX) \
|
||||||
|
XX(0, DELETE, DELETE) \
|
||||||
|
XX(1, GET, GET) \
|
||||||
|
XX(2, HEAD, HEAD) \
|
||||||
|
XX(3, POST, POST) \
|
||||||
|
XX(4, PUT, PUT) \
|
||||||
|
/* pathological */ \
|
||||||
|
XX(5, CONNECT, CONNECT) \
|
||||||
|
XX(6, OPTIONS, OPTIONS) \
|
||||||
|
XX(7, TRACE, TRACE) \
|
||||||
|
/* WebDAV */ \
|
||||||
|
XX(8, COPY, COPY) \
|
||||||
|
XX(9, LOCK, LOCK) \
|
||||||
|
XX(10, MKCOL, MKCOL) \
|
||||||
|
XX(11, MOVE, MOVE) \
|
||||||
|
XX(12, PROPFIND, PROPFIND) \
|
||||||
|
XX(13, PROPPATCH, PROPPATCH) \
|
||||||
|
XX(14, SEARCH, SEARCH) \
|
||||||
|
XX(15, UNLOCK, UNLOCK) \
|
||||||
|
XX(16, BIND, BIND) \
|
||||||
|
XX(17, REBIND, REBIND) \
|
||||||
|
XX(18, UNBIND, UNBIND) \
|
||||||
|
XX(19, ACL, ACL) \
|
||||||
|
/* subversion */ \
|
||||||
|
XX(20, REPORT, REPORT) \
|
||||||
|
XX(21, MKACTIVITY, MKACTIVITY) \
|
||||||
|
XX(22, CHECKOUT, CHECKOUT) \
|
||||||
|
XX(23, MERGE, MERGE) \
|
||||||
|
/* upnp */ \
|
||||||
|
XX(24, MSEARCH, M-SEARCH) \
|
||||||
|
XX(25, NOTIFY, NOTIFY) \
|
||||||
|
XX(26, SUBSCRIBE, SUBSCRIBE) \
|
||||||
|
XX(27, UNSUBSCRIBE, UNSUBSCRIBE) \
|
||||||
|
/* RFC-5789 */ \
|
||||||
|
XX(28, PATCH, PATCH) \
|
||||||
|
XX(29, PURGE, PURGE) \
|
||||||
|
/* CalDAV */ \
|
||||||
|
XX(30, MKCALENDAR, MKCALENDAR) \
|
||||||
|
/* RFC-2068, section 19.6.1.2 */ \
|
||||||
|
XX(31, LINK, LINK) \
|
||||||
|
XX(32, UNLINK, UNLINK) \
|
||||||
|
|
||||||
|
enum http_method
|
||||||
|
{
|
||||||
|
#define XX(num, name, string) HTTP_##name = num,
|
||||||
|
HTTP_METHOD_MAP(XX)
|
||||||
|
#undef XX
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
|
||||||
|
|
||||||
|
|
||||||
|
/* Flag values for http_parser.flags field */
|
||||||
|
enum flags
|
||||||
|
{ F_CHUNKED = 1 << 0
|
||||||
|
, F_CONNECTION_KEEP_ALIVE = 1 << 1
|
||||||
|
, F_CONNECTION_CLOSE = 1 << 2
|
||||||
|
, F_CONNECTION_UPGRADE = 1 << 3
|
||||||
|
, F_TRAILING = 1 << 4
|
||||||
|
, F_UPGRADE = 1 << 5
|
||||||
|
, F_SKIPBODY = 1 << 6
|
||||||
|
, F_CONTENTLENGTH = 1 << 7
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Map for errno-related constants
|
||||||
|
*
|
||||||
|
* The provided argument should be a macro that takes 2 arguments.
|
||||||
|
*/
|
||||||
|
#define HTTP_ERRNO_MAP(XX) \
|
||||||
|
/* No error */ \
|
||||||
|
XX(OK, "success") \
|
||||||
|
\
|
||||||
|
/* Callback-related errors */ \
|
||||||
|
XX(CB_message_begin, "the on_message_begin callback failed") \
|
||||||
|
XX(CB_url, "the on_url callback failed") \
|
||||||
|
XX(CB_header_field, "the on_header_field callback failed") \
|
||||||
|
XX(CB_header_value, "the on_header_value callback failed") \
|
||||||
|
XX(CB_headers_complete, "the on_headers_complete callback failed") \
|
||||||
|
XX(CB_body, "the on_body callback failed") \
|
||||||
|
XX(CB_message_complete, "the on_message_complete callback failed") \
|
||||||
|
XX(CB_status, "the on_status callback failed") \
|
||||||
|
XX(CB_chunk_header, "the on_chunk_header callback failed") \
|
||||||
|
XX(CB_chunk_complete, "the on_chunk_complete callback failed") \
|
||||||
|
\
|
||||||
|
/* Parsing-related errors */ \
|
||||||
|
XX(INVALID_EOF_STATE, "stream ended at an unexpected time") \
|
||||||
|
XX(HEADER_OVERFLOW, \
|
||||||
|
"too many header bytes seen; overflow detected") \
|
||||||
|
XX(CLOSED_CONNECTION, \
|
||||||
|
"data received after completed connection: close message") \
|
||||||
|
XX(INVALID_VERSION, "invalid HTTP version") \
|
||||||
|
XX(INVALID_STATUS, "invalid HTTP status code") \
|
||||||
|
XX(INVALID_METHOD, "invalid HTTP method") \
|
||||||
|
XX(INVALID_URL, "invalid URL") \
|
||||||
|
XX(INVALID_HOST, "invalid host") \
|
||||||
|
XX(INVALID_PORT, "invalid port") \
|
||||||
|
XX(INVALID_PATH, "invalid path") \
|
||||||
|
XX(INVALID_QUERY_STRING, "invalid query string") \
|
||||||
|
XX(INVALID_FRAGMENT, "invalid fragment") \
|
||||||
|
XX(LF_EXPECTED, "LF character expected") \
|
||||||
|
XX(INVALID_HEADER_TOKEN, "invalid character in header") \
|
||||||
|
XX(INVALID_CONTENT_LENGTH, \
|
||||||
|
"invalid character in content-length header") \
|
||||||
|
XX(UNEXPECTED_CONTENT_LENGTH, \
|
||||||
|
"unexpected content-length header") \
|
||||||
|
XX(INVALID_CHUNK_SIZE, \
|
||||||
|
"invalid character in chunk size header") \
|
||||||
|
XX(INVALID_CONSTANT, "invalid constant string") \
|
||||||
|
XX(INVALID_INTERNAL_STATE, "encountered unexpected internal state")\
|
||||||
|
XX(STRICT, "strict mode assertion failed") \
|
||||||
|
XX(PAUSED, "parser is paused") \
|
||||||
|
XX(UNKNOWN, "an unknown error occurred")
|
||||||
|
|
||||||
|
|
||||||
|
/* Define HPE_* values for each errno value above */
|
||||||
|
#define HTTP_ERRNO_GEN(n, s) HPE_##n,
|
||||||
|
enum http_errno {
|
||||||
|
HTTP_ERRNO_MAP(HTTP_ERRNO_GEN)
|
||||||
|
};
|
||||||
|
#undef HTTP_ERRNO_GEN
|
||||||
|
|
||||||
|
|
||||||
|
/* Get an http_errno value from an http_parser */
|
||||||
|
#define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno)
|
||||||
|
|
||||||
|
|
||||||
|
struct http_parser {
|
||||||
|
/** PRIVATE **/
|
||||||
|
unsigned int type : 2; /* enum http_parser_type */
|
||||||
|
unsigned int flags : 8; /* F_* values from 'flags' enum; semi-public */
|
||||||
|
unsigned int state : 7; /* enum state from http_parser.c */
|
||||||
|
unsigned int header_state : 7; /* enum header_state from http_parser.c */
|
||||||
|
unsigned int index : 7; /* index into current matcher */
|
||||||
|
unsigned int lenient_http_headers : 1;
|
||||||
|
|
||||||
|
uint32_t nread; /* # bytes read in various scenarios */
|
||||||
|
uint64_t content_length; /* # bytes in body (0 if no Content-Length header) */
|
||||||
|
|
||||||
|
/** READ-ONLY **/
|
||||||
|
unsigned short http_major;
|
||||||
|
unsigned short http_minor;
|
||||||
|
unsigned int status_code : 16; /* responses only */
|
||||||
|
unsigned int method : 8; /* requests only */
|
||||||
|
unsigned int http_errno : 7;
|
||||||
|
|
||||||
|
/* 1 = Upgrade header was present and the parser has exited because of that.
|
||||||
|
* 0 = No upgrade header present.
|
||||||
|
* Should be checked when http_parser_execute() returns in addition to
|
||||||
|
* error checking.
|
||||||
|
*/
|
||||||
|
unsigned int upgrade : 1;
|
||||||
|
|
||||||
|
/** PUBLIC **/
|
||||||
|
void *data; /* A pointer to get hook to the "connection" or "socket" object */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct http_parser_settings {
|
||||||
|
http_cb on_message_begin;
|
||||||
|
http_data_cb on_url;
|
||||||
|
http_data_cb on_status;
|
||||||
|
http_data_cb on_header_field;
|
||||||
|
http_data_cb on_header_value;
|
||||||
|
http_cb on_headers_complete;
|
||||||
|
http_data_cb on_body;
|
||||||
|
http_cb on_message_complete;
|
||||||
|
/* When on_chunk_header is called, the current chunk length is stored
|
||||||
|
* in parser->content_length.
|
||||||
|
*/
|
||||||
|
http_cb on_chunk_header;
|
||||||
|
http_cb on_chunk_complete;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum http_parser_url_fields
|
||||||
|
{ UF_SCHEMA = 0
|
||||||
|
, UF_HOST = 1
|
||||||
|
, UF_PORT = 2
|
||||||
|
, UF_PATH = 3
|
||||||
|
, UF_QUERY = 4
|
||||||
|
, UF_FRAGMENT = 5
|
||||||
|
, UF_USERINFO = 6
|
||||||
|
, UF_MAX = 7
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Result structure for http_parser_parse_url().
|
||||||
|
*
|
||||||
|
* Callers should index into field_data[] with UF_* values iff field_set
|
||||||
|
* has the relevant (1 << UF_*) bit set. As a courtesy to clients (and
|
||||||
|
* because we probably have padding left over), we convert any port to
|
||||||
|
* a uint16_t.
|
||||||
|
*/
|
||||||
|
struct http_parser_url {
|
||||||
|
uint16_t field_set; /* Bitmask of (1 << UF_*) values */
|
||||||
|
uint16_t port; /* Converted UF_PORT string */
|
||||||
|
|
||||||
|
struct {
|
||||||
|
uint16_t off; /* Offset into buffer in which field starts */
|
||||||
|
uint16_t len; /* Length of run in buffer */
|
||||||
|
} field_data[UF_MAX];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Returns the library version. Bits 16-23 contain the major version number,
|
||||||
|
* bits 8-15 the minor version number and bits 0-7 the patch level.
|
||||||
|
* Usage example:
|
||||||
|
*
|
||||||
|
* unsigned long version = http_parser_version();
|
||||||
|
* unsigned major = (version >> 16) & 255;
|
||||||
|
* unsigned minor = (version >> 8) & 255;
|
||||||
|
* unsigned patch = version & 255;
|
||||||
|
* printf("http_parser v%u.%u.%u\n", major, minor, patch);
|
||||||
|
*/
|
||||||
|
unsigned long http_parser_version(void);
|
||||||
|
|
||||||
|
void http_parser_init(http_parser *parser, enum http_parser_type type);
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialize http_parser_settings members to 0
|
||||||
|
*/
|
||||||
|
void http_parser_settings_init(http_parser_settings *settings);
|
||||||
|
|
||||||
|
|
||||||
|
/* Executes the parser. Returns number of parsed bytes. Sets
|
||||||
|
* `parser->http_errno` on error. */
|
||||||
|
size_t http_parser_execute(http_parser *parser,
|
||||||
|
const http_parser_settings *settings,
|
||||||
|
const char *data,
|
||||||
|
size_t len);
|
||||||
|
|
||||||
|
|
||||||
|
/* If http_should_keep_alive() in the on_headers_complete or
|
||||||
|
* on_message_complete callback returns 0, then this should be
|
||||||
|
* the last message on the connection.
|
||||||
|
* If you are the server, respond with the "Connection: close" header.
|
||||||
|
* If you are the client, close the connection.
|
||||||
|
*/
|
||||||
|
int http_should_keep_alive(const http_parser *parser);
|
||||||
|
|
||||||
|
/* Returns a string version of the HTTP method. */
|
||||||
|
const char *http_method_str(enum http_method m);
|
||||||
|
|
||||||
|
/* Return a string name of the given error */
|
||||||
|
const char *http_errno_name(enum http_errno err);
|
||||||
|
|
||||||
|
/* Return a string description of the given error */
|
||||||
|
const char *http_errno_description(enum http_errno err);
|
||||||
|
|
||||||
|
/* Initialize all http_parser_url members to 0 */
|
||||||
|
void http_parser_url_init(struct http_parser_url *u);
|
||||||
|
|
||||||
|
/* Parse a URL; return nonzero on failure */
|
||||||
|
int http_parser_parse_url(const char *buf, size_t buflen,
|
||||||
|
int is_connect,
|
||||||
|
struct http_parser_url *u);
|
||||||
|
|
||||||
|
/* Pause or un-pause the parser; a nonzero value pauses */
|
||||||
|
void http_parser_pause(http_parser *parser, int paused);
|
||||||
|
|
||||||
|
/* Checks if this is the final chunk of the body. */
|
||||||
|
int http_body_is_final(const http_parser *parser);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
@@ -9,39 +9,40 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// Typealias for a closure that handles an incoming HTTP request
|
/// Typealias for a closure that handles an incoming HTTP request
|
||||||
/// - Parameter req: the incoming HTTP request.
|
/// The following is an example of an echo `HTTPRequestHandler` that returns the request it receives as a response:
|
||||||
/// - 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:
|
|
||||||
/// ```swift
|
/// ```swift
|
||||||
/// class EchoWebApp: WebAppContaining {
|
/// func echo(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||||
/// func serve(req: HTTPRequest, res: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
/// response.writeHeader(status: .ok)
|
||||||
/// res.writeHeader(status: .ok, headers: [:])
|
/// return .processBody { (chunk, stop) in
|
||||||
/// return .processBody { (chunk, stop) in
|
/// switch chunk {
|
||||||
/// switch chunk {
|
/// case .chunk(let data, let finishedProcessing):
|
||||||
/// case .chunk(let data, let finishedProcessing):
|
/// response.writeBody(data) { _ in
|
||||||
/// res.writeBody(data) { _ in
|
/// finishedProcessing()
|
||||||
/// finishedProcessing()
|
|
||||||
/// }
|
|
||||||
/// case .end:
|
|
||||||
/// res.done()
|
|
||||||
/// default:
|
|
||||||
/// stop = true
|
|
||||||
/// res.abort()
|
|
||||||
/// }
|
/// }
|
||||||
|
/// case .end:
|
||||||
|
/// response.done()
|
||||||
|
/// default:
|
||||||
|
/// stop = true
|
||||||
|
/// response.abort()
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
public protocol WebAppContaining: class {
|
/// This then needs to be registered with the server using `HTTPServer.start(port:handler:)`
|
||||||
/// serve: function called when a new HTTP request is received by the HTTP server.
|
/// - Parameter req: the incoming HTTP request.
|
||||||
/// - Parameter req: the incoming HTTP request.
|
/// - Parameter res: a writer providing functions to create an HTTP reponse to the request.
|
||||||
/// - Parameter res: an 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.
|
/// - 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
|
/// The result returned as part of a completion handler
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public struct HTTPHeaders {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension HTTPHeaders : ExpressibleByDictionaryLiteral {
|
extension HTTPHeaders: ExpressibleByDictionaryLiteral {
|
||||||
/// Creates HTTP headers.
|
/// Creates HTTP headers.
|
||||||
public init(dictionaryLiteral: (Name, String)...) {
|
public init(dictionaryLiteral: (Name, String)...) {
|
||||||
storage = [:]
|
storage = [:]
|
||||||
@@ -58,7 +58,7 @@ extension HTTPHeaders : ExpressibleByDictionaryLiteral {
|
|||||||
extension HTTPHeaders {
|
extension HTTPHeaders {
|
||||||
// Used instead of HTTPHeaders to save CPU on dictionary construction
|
// Used instead of HTTPHeaders to save CPU on dictionary construction
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public struct Literal : ExpressibleByDictionaryLiteral {
|
public struct Literal: ExpressibleByDictionaryLiteral {
|
||||||
let fields: [(name: Name, value: String)]
|
let fields: [(name: Name, value: String)]
|
||||||
|
|
||||||
public init(dictionaryLiteral: (Name, String)...) {
|
public init(dictionaryLiteral: (Name, String)...) {
|
||||||
@@ -92,7 +92,7 @@ extension HTTPHeaders {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension HTTPHeaders : Sequence {
|
extension HTTPHeaders: Sequence {
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public func makeIterator() -> AnyIterator<(name: Name, value: String)> {
|
public func makeIterator() -> AnyIterator<(name: Name, value: String)> {
|
||||||
if let original = original {
|
if let original = original {
|
||||||
@@ -102,7 +102,7 @@ extension HTTPHeaders : Sequence {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StorageIterator : IteratorProtocol {
|
struct StorageIterator: IteratorProtocol {
|
||||||
var headers: DictionaryIterator<Name, [String]>
|
var headers: DictionaryIterator<Name, [String]>
|
||||||
var header: (name: Name, values: IndexingIterator<[String]>)?
|
var header: (name: Name, values: IndexingIterator<[String]>)?
|
||||||
|
|
||||||
@@ -126,9 +126,8 @@ extension HTTPHeaders : Sequence {
|
|||||||
|
|
||||||
/// HTTPHeaders structure.
|
/// HTTPHeaders structure.
|
||||||
extension HTTPHeaders {
|
extension HTTPHeaders {
|
||||||
|
|
||||||
/// Type used for the name of a HTTP header in the `HTTPHeaders` storage.
|
/// 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 original: String
|
||||||
let lowercased: String
|
let lowercased: String
|
||||||
public let hashValue: Int
|
public let hashValue: Int
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ extension HTTPMethod {
|
|||||||
/// LOCK method.
|
/// LOCK method.
|
||||||
public static let lock = HTTPMethod("LOCK")
|
public static let lock = HTTPMethod("LOCK")
|
||||||
/// MKCOL method.
|
/// MKCOL method.
|
||||||
public static let mkol = HTTPMethod("MKCOL")
|
public static let mkcol = HTTPMethod("MKCOL")
|
||||||
/// MOVE method.
|
/// MOVE method.
|
||||||
public static let move = HTTPMethod("MOVE")
|
public static let move = HTTPMethod("MOVE")
|
||||||
/// PROPFIND method.
|
/// PROPFIND method.
|
||||||
@@ -87,8 +87,7 @@ extension HTTPMethod {
|
|||||||
public static let unlink = HTTPMethod("UNLINK")
|
public static let unlink = HTTPMethod("UNLINK")
|
||||||
}
|
}
|
||||||
|
|
||||||
extension HTTPMethod : Hashable {
|
extension HTTPMethod: Hashable {
|
||||||
|
|
||||||
public var hashValue: Int {
|
public var hashValue: Int {
|
||||||
return method.hashValue
|
return method.hashValue
|
||||||
}
|
}
|
||||||
@@ -104,7 +103,7 @@ extension HTTPMethod : Hashable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension HTTPMethod : ExpressibleByStringLiteral {
|
extension HTTPMethod: ExpressibleByStringLiteral {
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public init(stringLiteral: String) {
|
public init(stringLiteral: String) {
|
||||||
self.init(stringLiteral)
|
self.init(stringLiteral)
|
||||||
@@ -121,7 +120,7 @@ extension HTTPMethod : ExpressibleByStringLiteral {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension HTTPMethod : CustomStringConvertible {
|
extension HTTPMethod: CustomStringConvertible {
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public var description: String {
|
public var description: String {
|
||||||
return method
|
return method
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
// See http://swift.org/LICENSE.txt for license information
|
// See http://swift.org/LICENSE.txt for license information
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import Dispatch
|
import Dispatch
|
||||||
|
import Foundation
|
||||||
|
|
||||||
/// A structure representing the headers from a HTTP request, without the body of the request.
|
/// A structure representing the headers from a HTTP request, without the body of the request.
|
||||||
public struct HTTPRequest {
|
public struct HTTPRequest {
|
||||||
@@ -21,16 +21,16 @@ public struct HTTPRequest {
|
|||||||
public var headers: HTTPHeaders
|
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 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
|
public typealias HTTPBodyHandler = (HTTPBodyChunk, inout Bool) -> Void
|
||||||
|
|
||||||
/// Indicates whether the body is going to be processed or ignored
|
/// Indicates whether the body is going to be processed or ignored
|
||||||
public enum HTTPBodyProcessing {
|
public enum HTTPBodyProcessing {
|
||||||
/// Used to discard the body data associated with the incoming HTTP request
|
/// Used to discard the body data associated with the incoming HTTP request
|
||||||
case discardBody
|
case discardBody
|
||||||
/// Used to process the body data associated with the imcoming HTTP request using a `HTTPBodyHandler`
|
/// Used to process the body data associated with the incoming HTTP request using a `HTTPBodyHandler`
|
||||||
case processBody(handler: HTTPBodyHandler)
|
case processBody(handler: HTTPBodyHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import Dispatch
|
|||||||
/// A structure representing the headers for a HTTP response, without the body of the response.
|
/// A structure representing the headers for a HTTP response, without the body of the response.
|
||||||
public struct HTTPResponse {
|
public struct HTTPResponse {
|
||||||
/// HTTP response version
|
/// HTTP response version
|
||||||
public var httpVersion : HTTPVersion
|
public var httpVersion: HTTPVersion
|
||||||
/// HTTP response status
|
/// HTTP response status
|
||||||
public var status: HTTPResponseStatus
|
public var status: HTTPResponseStatus
|
||||||
/// HTTP response headers
|
/// HTTP response headers
|
||||||
@@ -20,26 +20,25 @@ public struct HTTPResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// HTTPResponseWriter provides functions to create an HTTP response
|
/// HTTPResponseWriter provides functions to create an HTTP response
|
||||||
public protocol HTTPResponseWriter : class {
|
public protocol HTTPResponseWriter: class {
|
||||||
|
/// Writer function to create the headers for an HTTP response
|
||||||
/// writeHeader: Writer function to create the headers for an HTTP response
|
|
||||||
/// - Parameter status: The status code to include in the 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 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
|
/// - 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)
|
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 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
|
/// - Parameter completion: Closure that is called when the trailers has been written to the HTTP response
|
||||||
/// This is not currently implemented
|
/// This is not currently implemented
|
||||||
func writeTrailer(_ trailers: HTTPHeaders, completion: @escaping (Result) -> Void)
|
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 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
|
/// - Parameter completion: Closure that is called when the data has been written to the HTTP response
|
||||||
func writeBody(_ data: UnsafeHTTPResponseBody, completion: @escaping (Result) -> Void)
|
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
|
/// - Parameter completion: Closure that is called when the HTTP response has been completed
|
||||||
func done(completion: @escaping (Result) -> Void)
|
func done(completion: @escaping (Result) -> Void)
|
||||||
|
|
||||||
@@ -49,13 +48,13 @@ public protocol HTTPResponseWriter : class {
|
|||||||
|
|
||||||
/// Convenience methods for HTTP response writer.
|
/// Convenience methods for HTTP response writer.
|
||||||
extension HTTPResponseWriter {
|
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:)`
|
/// - See: `writeHeader(status:headers:completion:)`
|
||||||
public func writeHeader(status: HTTPResponseStatus, headers: HTTPHeaders) {
|
public func writeHeader(status: HTTPResponseStatus, headers: HTTPHeaders) {
|
||||||
writeHeader(status: status, headers: headers) { _ in }
|
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:)`
|
/// - See: `writeHeader(status:headers:completion:)`
|
||||||
public func writeHeader(status: HTTPResponseStatus) {
|
public func writeHeader(status: HTTPResponseStatus) {
|
||||||
writeHeader(status: status, headers: [:])
|
writeHeader(status: status, headers: [:])
|
||||||
@@ -226,6 +225,7 @@ public struct HTTPResponseStatus: Equatable, CustomStringConvertible, Expressibl
|
|||||||
/// 511 Network Authentication Required
|
/// 511 Network Authentication Required
|
||||||
public static let networkAuthenticationRequired = HTTPResponseStatus(code: 511)
|
public static let networkAuthenticationRequired = HTTPResponseStatus(code: 511)
|
||||||
|
|
||||||
|
// swiftlint:disable cyclomatic_complexity switch_case_on_newline
|
||||||
static func defaultReasonPhrase(forCode code: Int) -> String {
|
static func defaultReasonPhrase(forCode code: Int) -> String {
|
||||||
switch code {
|
switch code {
|
||||||
case 100: return "Continue"
|
case 100: return "Continue"
|
||||||
@@ -349,7 +349,7 @@ public struct HTTPResponseStatus: Equatable, CustomStringConvertible, Expressibl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public static func ==(lhs: HTTPResponseStatus, rhs: HTTPResponseStatus) -> Bool {
|
public static func == (lhs: HTTPResponseStatus, rhs: HTTPResponseStatus) -> Bool {
|
||||||
return lhs.code == rhs.code
|
return lhs.code == rhs.code
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -360,30 +360,30 @@ public protocol UnsafeHTTPResponseBody {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
extension UnsafeRawBufferPointer : UnsafeHTTPResponseBody {
|
extension UnsafeRawBufferPointer: UnsafeHTTPResponseBody {
|
||||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
||||||
return try body(self)
|
return try body(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public protocol HTTPResponseBody : UnsafeHTTPResponseBody {}
|
public protocol HTTPResponseBody: UnsafeHTTPResponseBody {}
|
||||||
|
|
||||||
extension Data : HTTPResponseBody {
|
extension Data: HTTPResponseBody {
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
||||||
return try withUnsafeBytes { try body(UnsafeRawBufferPointer(start: $0, count: count)) }
|
return try withUnsafeBytes { try body(UnsafeRawBufferPointer(start: $0, count: count)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension DispatchData : HTTPResponseBody {
|
extension DispatchData: HTTPResponseBody {
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
||||||
return try withUnsafeBytes { try body(UnsafeRawBufferPointer(start: $0, count: count)) }
|
return try withUnsafeBytes { try body(UnsafeRawBufferPointer(start: $0, count: count)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension String : HTTPResponseBody {
|
extension String: HTTPResponseBody {
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
public func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R {
|
||||||
return try ContiguousArray(utf8).withUnsafeBytes(body)
|
return try ContiguousArray(utf8).withUnsafeBytes(body)
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
// This source file is part of the Swift.org Server APIs open source project
|
||||||
|
//
|
||||||
|
// Copyright (c) 2017 Swift Server API project authors
|
||||||
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||||
|
//
|
||||||
|
// See http://swift.org/LICENSE.txt for license information
|
||||||
|
//
|
||||||
|
|
||||||
|
import ServerSecurity
|
||||||
|
|
||||||
|
/// A basic HTTP server. Currently this is implemented using the PoCSocket
|
||||||
|
/// abstraction, but the intention is to remove this dependency and reimplement
|
||||||
|
/// the class using transport APIs provided by the Server APIs working group.
|
||||||
|
public class HTTPServer {
|
||||||
|
|
||||||
|
/// Configuration options for creating HTTPServer
|
||||||
|
open class Options {
|
||||||
|
/// HTTPServer to be created on a given `port`
|
||||||
|
/// Note: For Port=0, the kernel assigns a random port. This will cause HTTPServer.port value
|
||||||
|
/// to diverge from HTTPServer.Options.port
|
||||||
|
public let port: Int
|
||||||
|
|
||||||
|
public let tlsConfig: TLSConfiguration?
|
||||||
|
|
||||||
|
/// Create an instance of HTTPServerOptions
|
||||||
|
public init(onPort: Int = 0, tlsConf: TLSConfiguration? = nil) {
|
||||||
|
port = onPort
|
||||||
|
tlsConfig = tlsConf
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public let options: Options
|
||||||
|
|
||||||
|
/// To process incoming requests
|
||||||
|
public let handler: HTTPRequestHandler
|
||||||
|
|
||||||
|
private let server = PoCSocketSimpleServer()
|
||||||
|
|
||||||
|
/// Create an instance of the server. This needs to be followed with a call to `start(port:handler:)`
|
||||||
|
public init(with newOptions: Options, requestHandler: @escaping HTTPRequestHandler) {
|
||||||
|
options = newOptions
|
||||||
|
handler = requestHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Start the HTTP server on the given `port` number, using a `HTTPRequestHandler` to process incoming requests.
|
||||||
|
public func start() throws {
|
||||||
|
try server.start(port: options.port, tls: options.tlsConfig, handler: handler)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Stop the server
|
||||||
|
public func stop() {
|
||||||
|
server.stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The port number the server is listening on
|
||||||
|
public var port: Int {
|
||||||
|
return server.port
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The number of current connections
|
||||||
|
public var connectionCount: Int {
|
||||||
|
return server.connectionCount
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,25 +6,26 @@
|
|||||||
// See http://swift.org/LICENSE.txt for license information
|
// See http://swift.org/LICENSE.txt for license information
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import CHTTPParser
|
||||||
import Foundation
|
import Foundation
|
||||||
import Dispatch
|
import Dispatch
|
||||||
|
|
||||||
import CHTTPParser
|
public enum StreamingParserError: Error {
|
||||||
|
case ConnectionAbortedError
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Class that wraps the CHTTPParser and calls the `HTTPRequestHandler` to get the response
|
||||||
/// Class that wraps the CHTTPParser and calls the `WebApp` to get the response
|
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public class StreamingParser: HTTPResponseWriter {
|
public class StreamingParser: HTTPResponseWriter {
|
||||||
|
|
||||||
let webapp: WebApp
|
let handle: HTTPRequestHandler
|
||||||
|
|
||||||
/// Time to leave socket open waiting for next request to start
|
/// Time to leave socket open waiting for next request to start
|
||||||
public static let keepAliveTimeout: TimeInterval = 5
|
public let keepAliveTimeout: TimeInterval
|
||||||
|
|
||||||
/// Flag to track if the client wants to send multiple requests on the same TCP connection
|
/// Flag to track if the client wants to send consecutive requests on the same TCP connection
|
||||||
var clientRequestedKeepAlive = false
|
var clientRequestedKeepAlive = false
|
||||||
|
|
||||||
|
|
||||||
/// Tracks when socket should be closed. Needs to have a lock, since it's updated often
|
/// Tracks when socket should be closed. Needs to have a lock, since it's updated often
|
||||||
private let _keepAliveUntilLock = DispatchSemaphore(value: 1)
|
private let _keepAliveUntilLock = DispatchSemaphore(value: 1)
|
||||||
private var _keepAliveUntil: TimeInterval?
|
private var _keepAliveUntil: TimeInterval?
|
||||||
@@ -45,17 +46,35 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Theoretical limit of how many open requests we can have. Used in Keep-Alive Header
|
/// Tracks when we've been told socket has been closed. Needs to have a lock, since if we get confused, bad things happen
|
||||||
let maxRequests = 100
|
private let _abortCalledLock = DispatchSemaphore(value: 1)
|
||||||
|
private var _abortCalled: Bool = false
|
||||||
|
internal var abortCalled: Bool {
|
||||||
|
get {
|
||||||
|
_abortCalledLock.wait()
|
||||||
|
defer {
|
||||||
|
_abortCalledLock.signal()
|
||||||
|
}
|
||||||
|
return _abortCalled
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
_abortCalledLock.wait()
|
||||||
|
defer {
|
||||||
|
_abortCalledLock.signal()
|
||||||
|
}
|
||||||
|
_abortCalled = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Optional delegate that can tell us how many connections are in-flight so we can set the Keep-Alive header
|
/// Optional delegate that can tell us how many connections are in-flight.
|
||||||
/// 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
|
|
||||||
public weak var connectionCounter: CurrentConnectionCounting?
|
public weak var connectionCounter: CurrentConnectionCounting?
|
||||||
|
|
||||||
/// Holds the bytes that come from the CHTTPParser until we have enough of them to do something with it
|
/// Holds the bytes that come from the CHTTPParser until we have enough of them to do something with it
|
||||||
var parserBuffer: Data?
|
var parserBuffer: Data?
|
||||||
|
|
||||||
|
/// Lock for parser buffer.
|
||||||
|
private let _parserBufferLock = DispatchSemaphore(value: 1)
|
||||||
|
|
||||||
/// HTTP Parser
|
/// HTTP Parser
|
||||||
var httpParser = http_parser()
|
var httpParser = http_parser()
|
||||||
var httpParserSettings = http_parser_settings()
|
var httpParserSettings = http_parser_settings()
|
||||||
@@ -67,6 +86,26 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
/// Protocol that we use to send data (and status info) back to the Network layer
|
/// Protocol that we use to send data (and status info) back to the Network layer
|
||||||
public var parserConnector: ParserConnecting?
|
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 lastCallBack = CallbackRecord.idle
|
||||||
var lastHeaderName: String?
|
var lastHeaderName: String?
|
||||||
var parsedHeaders = HTTPHeaders()
|
var parsedHeaders = HTTPHeaders()
|
||||||
@@ -77,82 +116,80 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
/// Is the currently parsed request an upgrade request?
|
/// Is the currently parsed request an upgrade request?
|
||||||
public private(set) var upgradeRequested = false
|
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
|
/// - Parameter handler: function that is used to create the response
|
||||||
public init(webapp: @escaping WebApp, connectionCounter: CurrentConnectionCounting? = nil) {
|
public init(handler: @escaping HTTPRequestHandler, connectionCounter: CurrentConnectionCounting? = nil, keepAliveTimeout: Double = 5.0) {
|
||||||
self.webapp = webapp
|
self.handle = handler
|
||||||
self.connectionCounter = connectionCounter
|
self.connectionCounter = connectionCounter
|
||||||
|
self.keepAliveTimeout = keepAliveTimeout
|
||||||
|
|
||||||
//Set up all the callbacks for the CHTTPParser library
|
//Set up all the callbacks for the CHTTPParser library
|
||||||
httpParserSettings.on_message_begin = {
|
httpParserSettings.on_message_begin = { parser -> Int32 in
|
||||||
parser -> Int32 in
|
|
||||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||||
return Int32(0)
|
return Int32(0)
|
||||||
}
|
}
|
||||||
return listener.messageBegan()
|
return listener.messageBegan()
|
||||||
}
|
}
|
||||||
|
|
||||||
httpParserSettings.on_message_complete = {
|
httpParserSettings.on_message_complete = { parser -> Int32 in
|
||||||
parser -> Int32 in
|
|
||||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||||
return Int32(0)
|
return 0
|
||||||
}
|
}
|
||||||
return listener.messageCompleted()
|
return listener.messageCompleted()
|
||||||
}
|
}
|
||||||
|
|
||||||
httpParserSettings.on_headers_complete = {
|
httpParserSettings.on_headers_complete = { parser -> Int32 in
|
||||||
parser -> Int32 in
|
|
||||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||||
return Int32(0)
|
return 0
|
||||||
}
|
}
|
||||||
let methodId = parser?.pointee.method
|
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 major = Int(parser?.pointee.http_major ?? 0)
|
||||||
let minor = Int(parser?.pointee.http_minor ?? 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
|
//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 keepAlive = http_should_keep_alive(parser) == 1
|
||||||
let upgradeRequested = get_upgrade_value(parser) == 1
|
let upgradeRequested = parser?.pointee.upgrade == 1
|
||||||
|
|
||||||
return listener.headersCompleted(methodName: methodName, majorVersion: major, minorVersion: minor, keepAlive: keepAlive, upgrade: upgradeRequested)
|
return listener.headersCompleted(methodName: methodName,
|
||||||
|
majorVersion: major,
|
||||||
|
minorVersion: minor,
|
||||||
|
keepAlive: keepAlive,
|
||||||
|
upgrade: upgradeRequested)
|
||||||
}
|
}
|
||||||
|
|
||||||
httpParserSettings.on_header_field = {
|
httpParserSettings.on_header_field = { (parser, chunk, length) -> Int32 in
|
||||||
(parser, chunk, length) -> Int32 in
|
|
||||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||||
return Int32(0)
|
return 0
|
||||||
}
|
}
|
||||||
return listener.headerFieldReceived(data: chunk, length: length)
|
return listener.headerFieldReceived(data: chunk, length: length)
|
||||||
}
|
}
|
||||||
|
|
||||||
httpParserSettings.on_header_value = {
|
httpParserSettings.on_header_value = { (parser, chunk, length) -> Int32 in
|
||||||
(parser, chunk, length) -> Int32 in
|
|
||||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||||
return Int32(0)
|
return 0
|
||||||
}
|
}
|
||||||
return listener.headerValueReceived(data: chunk, length: length)
|
return listener.headerValueReceived(data: chunk, length: length)
|
||||||
}
|
}
|
||||||
|
|
||||||
httpParserSettings.on_body = {
|
httpParserSettings.on_body = { (parser, chunk, length) -> Int32 in
|
||||||
(parser, chunk, length) -> Int32 in
|
|
||||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||||
return Int32(0)
|
return 0
|
||||||
}
|
}
|
||||||
return listener.bodyReceived(data: chunk, length: length)
|
return listener.bodyReceived(data: chunk, length: length)
|
||||||
}
|
}
|
||||||
|
|
||||||
httpParserSettings.on_url = {
|
httpParserSettings.on_url = { (parser, chunk, length) -> Int32 in
|
||||||
(parser, chunk, length) -> Int32 in
|
|
||||||
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
guard let listener = StreamingParser.getSelf(parser: parser) else {
|
||||||
return Int32(0)
|
return 0
|
||||||
}
|
}
|
||||||
return listener.urlReceived(data: chunk, length: length)
|
return listener.urlReceived(data: chunk, length: length)
|
||||||
}
|
}
|
||||||
|
|
||||||
http_parser_init(&httpParser, HTTP_REQUEST)
|
http_parser_init(&httpParser, HTTP_REQUEST)
|
||||||
|
|
||||||
self.httpParser.data = Unmanaged.passUnretained(self).toOpaque()
|
self.httpParser.data = Unmanaged.passUnretained(self).toOpaque()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read a stream from the network, pass it to the parser and return number of bytes consumed
|
/// Read a stream from the network, pass it to the parser and return number of bytes consumed
|
||||||
@@ -175,38 +212,42 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
/// - Parameter currentCallBack: state we are entering, as specified by the CHTTPParser
|
/// - Parameter currentCallBack: state we are entering, as specified by the CHTTPParser
|
||||||
/// - Returns: Whether or not the state actually changed
|
/// - Returns: Whether or not the state actually changed
|
||||||
@discardableResult
|
@discardableResult
|
||||||
func processCurrentCallback(_ currentCallBack:CallbackRecord) -> Bool {
|
func processCurrentCallback(_ currentCallBack: CallbackRecord) -> Bool {
|
||||||
if lastCallBack == currentCallBack {
|
if lastCallBack == currentCallBack {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
_parserBufferLock.wait()
|
||||||
|
defer { _parserBufferLock.signal() }
|
||||||
switch lastCallBack {
|
switch lastCallBack {
|
||||||
case .headerFieldReceived:
|
case .headerFieldReceived:
|
||||||
if let parserBuffer = self.parserBuffer {
|
if let parserBuffer = self.parserBuffer {
|
||||||
self.lastHeaderName = String(data: parserBuffer, encoding: .utf8)
|
self.lastHeaderName = String(data: parserBuffer, encoding: .utf8)
|
||||||
self.parserBuffer=nil
|
self.parserBuffer = nil
|
||||||
} else {
|
} else {
|
||||||
print("Missing parserBuffer after \(lastCallBack)")
|
print("Missing parserBuffer after \(lastCallBack)")
|
||||||
}
|
}
|
||||||
case .headerValueReceived:
|
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.parsedHeaders.append([HTTPHeaders.Name(lastHeaderName): headerValue])
|
||||||
self.lastHeaderName = nil
|
self.lastHeaderName = nil
|
||||||
self.parserBuffer=nil
|
self.parserBuffer = nil
|
||||||
} else {
|
} else {
|
||||||
print("Missing parserBuffer after \(lastCallBack)")
|
print("Missing parserBuffer after \(lastCallBack)")
|
||||||
}
|
}
|
||||||
case .headersCompleted:
|
case .headersCompleted:
|
||||||
self.parserBuffer=nil
|
self.parserBuffer = nil
|
||||||
|
|
||||||
if !upgradeRequested {
|
if !upgradeRequested {
|
||||||
self.httpBodyProcessingCallback = self.webapp(self.createRequest(), self)
|
self.httpBodyProcessingCallback = self.handle(self.createRequest(), self)
|
||||||
}
|
}
|
||||||
case .urlReceived:
|
case .urlReceived:
|
||||||
if let parserBuffer = self.parserBuffer {
|
if let parserBuffer = self.parserBuffer {
|
||||||
//Under heaptrack, this may appear to leak via _CFGetTSDCreateIfNeeded,
|
//Under heaptrack, this may appear to leak via _CFGetTSDCreateIfNeeded,
|
||||||
// apparently, that's because it triggers thread metadata to be created
|
// apparently, that's because it triggers thread metadata to be created
|
||||||
self.parsedURL = String(data:parserBuffer, encoding: .utf8)
|
self.parsedURL = String(data: parserBuffer, encoding: .utf8)
|
||||||
self.parserBuffer=nil
|
self.parserBuffer = nil
|
||||||
} else {
|
} else {
|
||||||
print("Missing parserBuffer after \(lastCallBack)")
|
print("Missing parserBuffer after \(lastCallBack)")
|
||||||
}
|
}
|
||||||
@@ -232,10 +273,10 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
func messageCompleted() -> Int32 {
|
func messageCompleted() -> Int32 {
|
||||||
let didChangeState = processCurrentCallback(.messageCompleted)
|
let didChangeState = processCurrentCallback(.messageCompleted)
|
||||||
if let chunkHandler = self.httpBodyProcessingCallback, didChangeState {
|
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 {
|
switch chunkHandler {
|
||||||
case .processBody(let handler):
|
case .processBody(let handler):
|
||||||
handler(.end, &stop)
|
handler(.end, &dummy)
|
||||||
case .discardBody:
|
case .discardBody:
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
@@ -243,14 +284,18 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
return 0
|
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)
|
processCurrentCallback(.headersCompleted)
|
||||||
self.parsedHTTPMethod = HTTPMethod(methodName)
|
self.parsedHTTPMethod = HTTPMethod(methodName)
|
||||||
self.parsedHTTPVersion = HTTPVersion(major: majorVersion, minor: minorVersion)
|
self.parsedHTTPVersion = HTTPVersion(major: majorVersion, minor: minorVersion)
|
||||||
|
|
||||||
//This needs to be set here and not messageCompleted if it's going to work here
|
//This needs to be set here and not messageCompleted if it's going to work here
|
||||||
self.clientRequestedKeepAlive = keepAlive
|
self.clientRequestedKeepAlive = keepAlive
|
||||||
self.keepAliveUntil = Date(timeIntervalSinceNow: StreamingParser.keepAliveTimeout).timeIntervalSinceReferenceDate
|
self.keepAliveUntil = Date(timeIntervalSinceNow: keepAliveTimeout).timeIntervalSinceReferenceDate
|
||||||
self.upgradeRequested = upgrade
|
self.upgradeRequested = upgrade
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@@ -258,8 +303,15 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
func headerFieldReceived(data: UnsafePointer<Int8>?, length: Int) -> Int32 {
|
func headerFieldReceived(data: UnsafePointer<Int8>?, length: Int) -> Int32 {
|
||||||
processCurrentCallback(.headerFieldReceived)
|
processCurrentCallback(.headerFieldReceived)
|
||||||
guard let data = data else { return 0 }
|
guard let data = data else { return 0 }
|
||||||
|
_parserBufferLock.wait()
|
||||||
|
defer { _parserBufferLock.signal() }
|
||||||
|
|
||||||
data.withMemoryRebound(to: UInt8.self, capacity: length) { (ptr) -> Void in
|
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
|
return 0
|
||||||
}
|
}
|
||||||
@@ -267,8 +319,15 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
func headerValueReceived(data: UnsafePointer<Int8>?, length: Int) -> Int32 {
|
func headerValueReceived(data: UnsafePointer<Int8>?, length: Int) -> Int32 {
|
||||||
processCurrentCallback(.headerValueReceived)
|
processCurrentCallback(.headerValueReceived)
|
||||||
guard let data = data else { return 0 }
|
guard let data = data else { return 0 }
|
||||||
|
_parserBufferLock.wait()
|
||||||
|
defer { _parserBufferLock.signal() }
|
||||||
|
|
||||||
data.withMemoryRebound(to: UInt8.self, capacity: length) { (ptr) -> Void in
|
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
|
return 0
|
||||||
}
|
}
|
||||||
@@ -276,21 +335,29 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
func bodyReceived(data: UnsafePointer<Int8>?, length: Int) -> Int32 {
|
func bodyReceived(data: UnsafePointer<Int8>?, length: Int) -> Int32 {
|
||||||
processCurrentCallback(.bodyReceived)
|
processCurrentCallback(.bodyReceived)
|
||||||
guard let data = data else { return 0 }
|
guard let data = data else { return 0 }
|
||||||
|
if shouldStopProcessingBody {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
data.withMemoryRebound(to: UInt8.self, capacity: length) { (ptr) -> Void in
|
data.withMemoryRebound(to: UInt8.self, capacity: length) { (ptr) -> Void in
|
||||||
let buff = UnsafeBufferPointer<UInt8>(start: ptr, count: length)
|
#if swift(>=4.0)
|
||||||
let chunk = DispatchData(bytes:buff)
|
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 {
|
if let chunkHandler = self.httpBodyProcessingCallback {
|
||||||
var stop=false
|
switch chunkHandler {
|
||||||
var finished=false
|
|
||||||
while !stop && !finished {
|
|
||||||
switch chunkHandler {
|
|
||||||
case .processBody(let handler):
|
case .processBody(let handler):
|
||||||
handler(.chunk(data: chunk, finishedProcessing: {
|
//OK, this sucks. We can't access the value of the `inout` inside this block
|
||||||
finished=true
|
// due to exclusivity. Which means that if we were to pass a local variable, we'd
|
||||||
}), &stop)
|
// 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:
|
case .discardBody:
|
||||||
finished=true
|
break
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,8 +367,15 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
func urlReceived(data: UnsafePointer<Int8>?, length: Int) -> Int32 {
|
func urlReceived(data: UnsafePointer<Int8>?, length: Int) -> Int32 {
|
||||||
processCurrentCallback(.urlReceived)
|
processCurrentCallback(.urlReceived)
|
||||||
guard let data = data else { return 0 }
|
guard let data = data else { return 0 }
|
||||||
|
_parserBufferLock.wait()
|
||||||
|
defer { _parserBufferLock.signal() }
|
||||||
|
|
||||||
data.withMemoryRebound(to: UInt8.self, capacity: length) { (ptr) -> Void in
|
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
|
return 0
|
||||||
}
|
}
|
||||||
@@ -316,21 +390,24 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
|
|
||||||
/// Create a `HTTPRequest` struct from the parsed information
|
/// Create a `HTTPRequest` struct from the parsed information
|
||||||
public func createRequest() -> HTTPRequest {
|
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) {
|
public func writeHeader(status: HTTPResponseStatus, headers: HTTPHeaders, completion: @escaping (Result) -> Void) {
|
||||||
// TODO call completion()
|
|
||||||
guard !headersWritten else {
|
guard !headersWritten else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var header = "HTTP/1.1 \(status.code) \(status.reasonPhrase)\r\n"
|
var header = "HTTP/1.1 \(status.code) \(status.reasonPhrase)\r\n"
|
||||||
|
|
||||||
let isContinue = status == .continue
|
let isInformational = status.class == .informational
|
||||||
|
|
||||||
var headers = headers
|
var headers = headers
|
||||||
if !isContinue {
|
if !isInformational {
|
||||||
adjustHeaders(status: status, headers: &headers)
|
adjustHeaders(status: status, headers: &headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,12 +416,16 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
header += "\(key): \(value)\r\n"
|
header += "\(key): \(value)\r\n"
|
||||||
}
|
}
|
||||||
header.append("\r\n")
|
header.append("\r\n")
|
||||||
|
guard !abortCalled else {
|
||||||
|
completion(.error(StreamingParserError.ConnectionAbortedError))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME headers are US-ASCII, anything else should be encoded using [RFC5987] some lines above
|
// FIXME headers are US-ASCII, anything else should be encoded using [RFC5987] some lines above
|
||||||
// TODO use requested encoding if specified
|
// TODO use requested encoding if specified
|
||||||
if let data = header.data(using: .utf8) {
|
if let data = header.data(using: .utf8) {
|
||||||
self.parserConnector?.queueSocketWrite(data)
|
self.parserConnector?.queueSocketWrite(data, completion: completion)
|
||||||
if !isContinue {
|
if !isInformational {
|
||||||
headersWritten = true
|
headersWritten = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -375,11 +456,8 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
headers[.transferEncoding] = nil
|
headers[.transferEncoding] = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let availableConnections = maxRequests - (self.connectionCounter?.connectionCount ?? 0)
|
if clientRequestedKeepAlive {
|
||||||
|
|
||||||
if clientRequestedKeepAlive && (availableConnections > 0) {
|
|
||||||
headers[.connection] = "Keep-Alive"
|
headers[.connection] = "Keep-Alive"
|
||||||
headers[.keepAlive] = "timeout=\(Int(StreamingParser.keepAliveTimeout)), max=\(availableConnections)"
|
|
||||||
} else {
|
} else {
|
||||||
headers[.connection] = "Close"
|
headers[.connection] = "Close"
|
||||||
}
|
}
|
||||||
@@ -410,53 +488,66 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
dataToWrite.append(chunkEnd)
|
dataToWrite.append(chunkEnd)
|
||||||
return dataToWrite
|
return dataToWrite
|
||||||
}
|
}
|
||||||
} else if let d = data as? Data {
|
} else if let data = data as? Data {
|
||||||
dataToWrite = d
|
dataToWrite = data
|
||||||
} else {
|
} else {
|
||||||
dataToWrite = data.withUnsafeBytes { Data($0) }
|
dataToWrite = data.withUnsafeBytes { Data($0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
self.parserConnector?.queueSocketWrite(dataToWrite)
|
guard !abortCalled else {
|
||||||
|
completion(.error(StreamingParserError.ConnectionAbortedError))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
completion(.ok)
|
self.parserConnector?.queueSocketWrite(dataToWrite, completion: completion)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func done(completion: @escaping (Result) -> Void) {
|
public func done(completion: @escaping (Result) -> Void) {
|
||||||
|
guard !abortCalled else {
|
||||||
|
completion(.error(StreamingParserError.ConnectionAbortedError))
|
||||||
|
return
|
||||||
|
}
|
||||||
if isChunked {
|
if isChunked {
|
||||||
let chunkTerminate = "0\r\n\r\n".data(using: .utf8)!
|
let chunkTerminate = "0\r\n\r\n".data(using: .utf8)!
|
||||||
self.parserConnector?.queueSocketWrite(chunkTerminate)
|
self.parserConnector?.queueSocketWrite(chunkTerminate, completion: completion)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.parsedHTTPMethod = nil
|
self.parsedHTTPMethod = nil
|
||||||
self.parsedURL=nil
|
self.parsedURL = nil
|
||||||
self.parsedHeaders = HTTPHeaders()
|
self.parsedHeaders = HTTPHeaders()
|
||||||
self.lastHeaderName = nil
|
self.lastHeaderName = nil
|
||||||
|
_parserBufferLock.wait()
|
||||||
self.parserBuffer = nil
|
self.parserBuffer = nil
|
||||||
|
_parserBufferLock.signal()
|
||||||
self.parsedHTTPMethod = nil
|
self.parsedHTTPMethod = nil
|
||||||
self.parsedHTTPVersion = nil
|
self.parsedHTTPVersion = nil
|
||||||
self.lastCallBack = .idle
|
self.lastCallBack = .idle
|
||||||
self.headersWritten = false
|
self.headersWritten = false
|
||||||
self.httpBodyProcessingCallback = nil
|
self.httpBodyProcessingCallback = nil
|
||||||
self.upgradeRequested = false
|
self.upgradeRequested = false
|
||||||
|
self.shouldStopProcessingBody = false
|
||||||
|
|
||||||
let closeAfter = {
|
//Note: This used to be passed into the completion block that `Result` used to have
|
||||||
if self.clientRequestedKeepAlive {
|
// But since that block was removed, we're calling it directly
|
||||||
self.keepAliveUntil = Date(timeIntervalSinceNow:StreamingParser.keepAliveTimeout).timeIntervalSinceReferenceDate
|
if self.clientRequestedKeepAlive {
|
||||||
self.parserConnector?.responseComplete()
|
self.keepAliveUntil = Date(timeIntervalSinceNow: keepAliveTimeout).timeIntervalSinceReferenceDate
|
||||||
} else {
|
guard !abortCalled else {
|
||||||
self.parserConnector?.closeWriter()
|
completion(.error(StreamingParserError.ConnectionAbortedError))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
self.parserConnector?.responseComplete()
|
||||||
|
} else {
|
||||||
|
guard !abortCalled else {
|
||||||
|
completion(.error(StreamingParserError.ConnectionAbortedError))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
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)
|
completion(.ok)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func abort() {
|
public func abort() {
|
||||||
fatalError("abort called, not sure what to do with it")
|
abortCalled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
@@ -468,18 +559,20 @@ public class StreamingParser: HTTPResponseWriter {
|
|||||||
/// Protocol implemented by the thing that sits in between us and the network layer
|
/// Protocol implemented by the thing that sits in between us and the network layer
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public protocol ParserConnecting: class {
|
public protocol ParserConnecting: class {
|
||||||
|
|
||||||
/// Send data to the network do be written to the client
|
/// 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
|
/// 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
|
/// 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
|
/// 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
|
/// Delegate that can tell us how many connections are in-flight so we can set the Keep-Alive header
|
||||||
|
|||||||
@@ -20,12 +20,14 @@ public struct HTTPVersion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension HTTPVersion : Hashable {
|
extension HTTPVersion: Hashable {
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public var hashValue: Int {
|
public var hashValue: Int {
|
||||||
return (major << 8) | minor
|
return (major << 8) | minor
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension HTTPVersion {
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public static func == (lhs: HTTPVersion, rhs: HTTPVersion) -> Bool {
|
public static func == (lhs: HTTPVersion, rhs: HTTPVersion) -> Bool {
|
||||||
return lhs.major == rhs.major && lhs.minor == rhs.minor
|
return lhs.major == rhs.major && lhs.minor == rhs.minor
|
||||||
@@ -37,7 +39,7 @@ extension HTTPVersion : Hashable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension HTTPVersion : Comparable {
|
extension HTTPVersion: Comparable {
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public static func < (lhs: HTTPVersion, rhs: HTTPVersion) -> Bool {
|
public static func < (lhs: HTTPVersion, rhs: HTTPVersion) -> Bool {
|
||||||
if lhs.major != rhs.major {
|
if lhs.major != rhs.major {
|
||||||
@@ -46,12 +48,11 @@ extension HTTPVersion : Comparable {
|
|||||||
return lhs.minor < rhs.minor
|
return lhs.minor < rhs.minor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension HTTPVersion : CustomStringConvertible {
|
extension HTTPVersion: CustomStringConvertible {
|
||||||
/// :nodoc:
|
/// :nodoc:
|
||||||
public var description: String {
|
public var description: String {
|
||||||
return "HTTP/" + major.description + "." + minor.description
|
return "HTTP/\(major).\(minor)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,361 @@
|
|||||||
|
// This source file is part of the Swift.org Server APIs open source project
|
||||||
|
//
|
||||||
|
// Copyright (c) 2017 Swift Server API project authors
|
||||||
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||||
|
//
|
||||||
|
// See http://swift.org/LICENSE.txt for license information
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Dispatch
|
||||||
|
import ServerSecurity
|
||||||
|
|
||||||
|
///:nodoc:
|
||||||
|
public enum PoCSocketError: Error {
|
||||||
|
case SocketOSError(errno: Int32)
|
||||||
|
case InvalidSocketError
|
||||||
|
case InvalidReadLengthError
|
||||||
|
case InvalidWriteLengthError
|
||||||
|
case InvalidBufferError
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Simple Wrapper around the `socket(2)` functions we need for Proof of Concept testing
|
||||||
|
/// Intentionally a thin layer over `recv(2)`/`send(2)` so uses the same argument types.
|
||||||
|
/// Note that no method names here are the same as any system call names.
|
||||||
|
/// This is because we expect the caller might need functionality we haven't implemented here.
|
||||||
|
internal class PoCSocket: ConnectionDelegate {
|
||||||
|
|
||||||
|
/// hold the file descriptor for the socket supplied by the OS. `-1` is invalid socket
|
||||||
|
internal var socketfd: Int32 = -1
|
||||||
|
|
||||||
|
/// The TCP port the server is actually listening on. Set after system call completes
|
||||||
|
internal var listeningPort: Int32 = -1
|
||||||
|
|
||||||
|
/// Track state between `listen(2)` and `shutdown(2)`
|
||||||
|
private let _isListeningLock = DispatchSemaphore(value: 1)
|
||||||
|
private var _isListening: Bool = false
|
||||||
|
internal private(set) var isListening: Bool {
|
||||||
|
get {
|
||||||
|
_isListeningLock.wait()
|
||||||
|
defer {
|
||||||
|
_isListeningLock.signal()
|
||||||
|
}
|
||||||
|
return _isListening
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
_isListeningLock.wait()
|
||||||
|
defer {
|
||||||
|
_isListeningLock.signal()
|
||||||
|
}
|
||||||
|
_isListening = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Track state between `accept(2)/bind(2)` and `close(2)`
|
||||||
|
private let _isConnectedLock = DispatchSemaphore(value: 1)
|
||||||
|
private var _isConnected: Bool = false
|
||||||
|
internal private(set) var isConnected: Bool {
|
||||||
|
get {
|
||||||
|
_isConnectedLock.wait()
|
||||||
|
defer {
|
||||||
|
_isConnectedLock.signal()
|
||||||
|
}
|
||||||
|
return _isConnected
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
_isConnectedLock.wait()
|
||||||
|
defer {
|
||||||
|
_isConnectedLock.signal()
|
||||||
|
}
|
||||||
|
_isConnected = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// track whether a shutdown is in progress so we can suppress error messages
|
||||||
|
private let _isShuttingDownLock = DispatchSemaphore(value: 1)
|
||||||
|
private var _isShuttingDown: Bool = false
|
||||||
|
private var isShuttingDown: Bool {
|
||||||
|
get {
|
||||||
|
_isShuttingDownLock.wait()
|
||||||
|
defer {
|
||||||
|
_isShuttingDownLock.signal()
|
||||||
|
}
|
||||||
|
return _isShuttingDown
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
_isShuttingDownLock.wait()
|
||||||
|
defer {
|
||||||
|
_isShuttingDownLock.signal()
|
||||||
|
}
|
||||||
|
_isShuttingDown = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Delegate that provides the TLS implementation
|
||||||
|
public var TLSdelegate: TLSServiceDelegate? = nil
|
||||||
|
/// Return the file descriptor as a connection endpoint for ConnectionDelegate.
|
||||||
|
public var endpoint: ConnectionType {
|
||||||
|
get {
|
||||||
|
return ConnectionType.socket(self.socketfd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// track whether a the socket has already been closed.
|
||||||
|
private let _hasClosedLock = DispatchSemaphore(value: 1)
|
||||||
|
private var _hasClosed: Bool = false
|
||||||
|
private var hasClosed: Bool {
|
||||||
|
get {
|
||||||
|
_hasClosedLock.wait()
|
||||||
|
defer {
|
||||||
|
_hasClosedLock.signal()
|
||||||
|
}
|
||||||
|
return _hasClosed
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
_hasClosedLock.wait()
|
||||||
|
defer {
|
||||||
|
_hasClosedLock.signal()
|
||||||
|
}
|
||||||
|
_hasClosed = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Call recv(2) with buffer allocated by our caller and return the output
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - readBuffer: Buffer to read into. Note this needs to be `inout` because we're modfying it and we want Swift4+'s ownership checks to make sure no one else is at the same time
|
||||||
|
/// - maxLength: Max length that can be read. Buffer *must* be at least this big!!!
|
||||||
|
/// - Returns: Number of bytes read or -1 on failure as per `recv(2)`
|
||||||
|
/// - Throws: PoCSocketError if sanity checks fail
|
||||||
|
internal func socketRead(into readBuffer: inout UnsafeMutablePointer<Int8>, maxLength: Int) throws -> Int {
|
||||||
|
if maxLength <= 0 || maxLength > Int(Int32.max) {
|
||||||
|
throw PoCSocketError.InvalidReadLengthError
|
||||||
|
}
|
||||||
|
if socketfd <= 0 {
|
||||||
|
throw PoCSocketError.InvalidSocketError
|
||||||
|
}
|
||||||
|
|
||||||
|
//Make sure no one passed a nil pointer to us
|
||||||
|
let readBufferPointer: UnsafeMutablePointer<Int8>! = readBuffer
|
||||||
|
if readBufferPointer == nil {
|
||||||
|
throw PoCSocketError.InvalidBufferError
|
||||||
|
}
|
||||||
|
|
||||||
|
//Make sure data isn't re-used
|
||||||
|
readBuffer.initialize(to: 0x0, count: maxLength)
|
||||||
|
|
||||||
|
let read: Int
|
||||||
|
if let tls = self.TLSdelegate {
|
||||||
|
// HTTPS
|
||||||
|
read = try tls.willReceive(into: readBuffer, bufSize: maxLength)
|
||||||
|
} else {
|
||||||
|
// HTTP
|
||||||
|
read = recv(self.socketfd, readBuffer, maxLength, Int32(0))
|
||||||
|
}
|
||||||
|
//Leave this as a local variable to facilitate Setting a Watchpoint in lldb
|
||||||
|
return read
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Pass buffer passed into to us into send(2).
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - buffer: buffer containing data to write.
|
||||||
|
/// - bufSize: number of bytes to write. Buffer must be this long
|
||||||
|
/// - Returns: number of bytes written or -1. See `send(2)`
|
||||||
|
/// - Throws: PoCSocketError if sanity checks fail
|
||||||
|
@discardableResult internal func socketWrite(from buffer: UnsafeRawPointer, bufSize: Int) throws -> Int {
|
||||||
|
if socketfd <= 0 {
|
||||||
|
throw PoCSocketError.InvalidSocketError
|
||||||
|
}
|
||||||
|
if bufSize < 0 || bufSize > Int(Int32.max) {
|
||||||
|
throw PoCSocketError.InvalidWriteLengthError
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure we weren't handed a nil buffer
|
||||||
|
let writeBufferPointer: UnsafeRawPointer! = buffer
|
||||||
|
if writeBufferPointer == nil {
|
||||||
|
throw PoCSocketError.InvalidBufferError
|
||||||
|
}
|
||||||
|
|
||||||
|
let sent: Int
|
||||||
|
if let tls = self.TLSdelegate {
|
||||||
|
// HTTPS
|
||||||
|
sent = try tls.willSend(buffer: buffer, bufSize: Int(bufSize))
|
||||||
|
} else {
|
||||||
|
// HTTP
|
||||||
|
sent = send(self.socketfd, buffer, Int(bufSize), Int32(0))
|
||||||
|
}
|
||||||
|
//Leave this as a local variable to facilitate Setting a Watchpoint in lldb
|
||||||
|
return sent
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Calls `shutdown(2)` and `close(2)` on a socket
|
||||||
|
internal func shutdownAndClose() {
|
||||||
|
self.isShuttingDown = true
|
||||||
|
if let tls = self.TLSdelegate {
|
||||||
|
tls.willDestroy()
|
||||||
|
}
|
||||||
|
if socketfd < 1 {
|
||||||
|
//Nothing to do. Maybe it was closed already
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if hasClosed {
|
||||||
|
//Nothing to do. It was closed already
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if self.isListening || self.isConnected {
|
||||||
|
_ = shutdown(self.socketfd, Int32(SHUT_RDWR))
|
||||||
|
self.isListening = false
|
||||||
|
}
|
||||||
|
self.isConnected = false
|
||||||
|
close(self.socketfd)
|
||||||
|
self.hasClosed = true
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Thin wrapper around `accept(2)`
|
||||||
|
///
|
||||||
|
/// - Returns: PoCSocket object for newly connected socket or nil if we've been told to shutdown
|
||||||
|
/// - Throws: PoCSocketError on sanity check fails or if accept fails after several retries
|
||||||
|
internal func acceptClientConnection() throws -> PoCSocket? {
|
||||||
|
if socketfd <= 0 || !isListening {
|
||||||
|
throw PoCSocketError.InvalidSocketError
|
||||||
|
}
|
||||||
|
|
||||||
|
let retVal = PoCSocket()
|
||||||
|
|
||||||
|
var maxRetryCount = 100
|
||||||
|
|
||||||
|
var acceptFD: Int32 = -1
|
||||||
|
repeat {
|
||||||
|
var acceptAddr = sockaddr_in()
|
||||||
|
var addrSize = socklen_t(MemoryLayout<sockaddr_in>.size)
|
||||||
|
|
||||||
|
acceptFD = withUnsafeMutablePointer(to: &acceptAddr) { pointer in
|
||||||
|
return accept(self.socketfd, UnsafeMutableRawPointer(pointer).assumingMemoryBound(to: sockaddr.self), &addrSize)
|
||||||
|
}
|
||||||
|
if acceptFD < 0 && errno != EINTR {
|
||||||
|
//fail
|
||||||
|
if (isShuttingDown) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
maxRetryCount = maxRetryCount - 1
|
||||||
|
print("Could not accept on socket \(socketfd). Error is \(errno). Will retry.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while acceptFD < 0 && maxRetryCount > 0
|
||||||
|
|
||||||
|
if acceptFD < 0 {
|
||||||
|
throw PoCSocketError.SocketOSError(errno: errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
retVal.isConnected = true
|
||||||
|
retVal.socketfd = acceptFD
|
||||||
|
|
||||||
|
// TLS delegate does post accept handling and verification
|
||||||
|
if let tls = self.TLSdelegate {
|
||||||
|
try tls.didAccept(connection: retVal)
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal
|
||||||
|
}
|
||||||
|
|
||||||
|
/// call `bind(2)` and `listen(2)`
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - port: `sin_port` value, see `bind(2)`
|
||||||
|
/// - maxBacklogSize: backlog argument to `listen(2)`
|
||||||
|
/// - Throws: PoCSocketError
|
||||||
|
internal func bindAndListen(on port: Int = 0, maxBacklogSize: Int32 = 100) throws {
|
||||||
|
#if os(Linux)
|
||||||
|
socketfd = socket(Int32(AF_INET), Int32(SOCK_STREAM.rawValue), Int32(IPPROTO_TCP))
|
||||||
|
#else
|
||||||
|
socketfd = socket(Int32(AF_INET), Int32(SOCK_STREAM), Int32(IPPROTO_TCP))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if socketfd <= 0 {
|
||||||
|
throw PoCSocketError.InvalidSocketError
|
||||||
|
|
||||||
|
}
|
||||||
|
// Initialize delegate
|
||||||
|
if let tls = self.TLSdelegate {
|
||||||
|
try tls.didCreateServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
var on: Int32 = 1
|
||||||
|
// Allow address reuse
|
||||||
|
if setsockopt(self.socketfd, SOL_SOCKET, SO_REUSEADDR, &on, socklen_t(MemoryLayout<Int32>.size)) < 0 {
|
||||||
|
throw PoCSocketError.SocketOSError(errno: errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow port reuse
|
||||||
|
if setsockopt(self.socketfd, SOL_SOCKET, SO_REUSEPORT, &on, socklen_t(MemoryLayout<Int32>.size)) < 0 {
|
||||||
|
throw PoCSocketError.SocketOSError(errno: errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
#if os(Linux)
|
||||||
|
var addr = sockaddr_in(
|
||||||
|
sin_family: sa_family_t(AF_INET),
|
||||||
|
sin_port: htons(UInt16(port)),
|
||||||
|
sin_addr: in_addr(s_addr: in_addr_t(0)),
|
||||||
|
sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
|
||||||
|
#else
|
||||||
|
var addr = sockaddr_in(
|
||||||
|
sin_len: UInt8(MemoryLayout<sockaddr_in>.stride),
|
||||||
|
sin_family: UInt8(AF_INET),
|
||||||
|
sin_port: (Int(OSHostByteOrder()) != OSLittleEndian ? UInt16(port) : _OSSwapInt16(UInt16(port))),
|
||||||
|
sin_addr: in_addr(s_addr: in_addr_t(0)),
|
||||||
|
sin_zero: (0, 0, 0, 0, 0, 0, 0, 0))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_ = withUnsafePointer(to: &addr) {
|
||||||
|
bind(self.socketfd, UnsafePointer<sockaddr>(OpaquePointer($0)), socklen_t(MemoryLayout<sockaddr_in>.size))
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = listen(self.socketfd, maxBacklogSize)
|
||||||
|
|
||||||
|
isListening = true
|
||||||
|
|
||||||
|
var addr_in = sockaddr_in()
|
||||||
|
|
||||||
|
listeningPort = try withUnsafePointer(to: &addr_in) { pointer in
|
||||||
|
var len = socklen_t(MemoryLayout<sockaddr_in>.size)
|
||||||
|
if getsockname(socketfd, UnsafeMutablePointer(OpaquePointer(pointer)), &len) != 0 {
|
||||||
|
throw PoCSocketError.SocketOSError(errno: errno)
|
||||||
|
}
|
||||||
|
#if os(Linux)
|
||||||
|
return Int32(ntohs(addr_in.sin_port))
|
||||||
|
#else
|
||||||
|
return Int32(Int(OSHostByteOrder()) != OSLittleEndian ? addr_in.sin_port.littleEndian : addr_in.sin_port.bigEndian)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check to see if socket is being used
|
||||||
|
///
|
||||||
|
/// - Returns: whether socket is listening or connected
|
||||||
|
internal func isOpen() -> Bool {
|
||||||
|
return isListening || isConnected
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the socket to Blocking or non-blocking mode.
|
||||||
|
///
|
||||||
|
/// - Parameter mode: true for blocking, false for nonBlocking
|
||||||
|
/// - Returns: `fcntl(2)` flags
|
||||||
|
/// - Throws: PoCSocketError if `fcntl` fails
|
||||||
|
@discardableResult internal func setBlocking(mode: Bool) throws -> Int32 {
|
||||||
|
let flags = fcntl(self.socketfd, F_GETFL)
|
||||||
|
if flags < 0 {
|
||||||
|
//Failed
|
||||||
|
throw PoCSocketError.SocketOSError(errno: errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
let newFlags = mode ? flags & ~O_NONBLOCK : flags | O_NONBLOCK
|
||||||
|
|
||||||
|
let result = fcntl(self.socketfd, F_SETFL, newFlags)
|
||||||
|
if result < 0 {
|
||||||
|
//Failed
|
||||||
|
throw PoCSocketError.SocketOSError(errno: errno)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,393 @@
|
|||||||
|
// This source file is part of the Swift.org Server APIs open source project
|
||||||
|
//
|
||||||
|
// Copyright (c) 2017 Swift Server API project authors
|
||||||
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||||
|
//
|
||||||
|
// See http://swift.org/LICENSE.txt for license information
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import Dispatch
|
||||||
|
import ServerSecurity
|
||||||
|
|
||||||
|
///:nodoc:
|
||||||
|
public class PoCSocketConnectionListener: ParserConnecting {
|
||||||
|
|
||||||
|
/// socket(2) wrapper object
|
||||||
|
var socket: PoCSocket?
|
||||||
|
|
||||||
|
/// ivar for the thing that manages the CHTTP Parser
|
||||||
|
var parser: StreamingParser?
|
||||||
|
|
||||||
|
/// Save the socket file descriptor so we can loook at it for debugging purposes
|
||||||
|
var socketFD: Int32
|
||||||
|
///Flag to track whether we've been told to shutdown or not (with lock)
|
||||||
|
private let _shouldShutdownLock = DispatchSemaphore(value: 1)
|
||||||
|
private var _shouldShutdown: Bool = false
|
||||||
|
var shouldShutdown: Bool {
|
||||||
|
get {
|
||||||
|
_shouldShutdownLock.wait()
|
||||||
|
defer {
|
||||||
|
_shouldShutdownLock.signal()
|
||||||
|
}
|
||||||
|
return _shouldShutdown
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
_shouldShutdownLock.wait()
|
||||||
|
defer {
|
||||||
|
_shouldShutdownLock.signal()
|
||||||
|
}
|
||||||
|
_shouldShutdown = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Queues for managing access to the socket without blocking the world
|
||||||
|
let socketReaderQueue: DispatchQueue
|
||||||
|
let socketWriterQueue: DispatchQueue
|
||||||
|
|
||||||
|
/// Event handler for reading from the socket
|
||||||
|
private var readerSource: DispatchSourceRead?
|
||||||
|
|
||||||
|
/// Flag to track whether we're in the middle of a response or not (with lock)
|
||||||
|
private let _responseCompletedLock = DispatchSemaphore(value: 1)
|
||||||
|
private var _responseCompleted: Bool = false
|
||||||
|
var responseCompleted: Bool {
|
||||||
|
get {
|
||||||
|
_responseCompletedLock.wait()
|
||||||
|
defer {
|
||||||
|
_responseCompletedLock.signal()
|
||||||
|
}
|
||||||
|
return _responseCompleted
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
_responseCompletedLock.wait()
|
||||||
|
defer {
|
||||||
|
_responseCompletedLock.signal()
|
||||||
|
}
|
||||||
|
_responseCompleted = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Flag to track whether we've received a socket error or not (with lock)
|
||||||
|
private let _errorOccurredLock = DispatchSemaphore(value: 1)
|
||||||
|
private var _errorOccurred: Bool = false
|
||||||
|
var errorOccurred: Bool {
|
||||||
|
get {
|
||||||
|
_errorOccurredLock.wait()
|
||||||
|
defer {
|
||||||
|
_errorOccurredLock.signal()
|
||||||
|
}
|
||||||
|
return _errorOccurred
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
_errorOccurredLock.wait()
|
||||||
|
defer {
|
||||||
|
_errorOccurredLock.signal()
|
||||||
|
}
|
||||||
|
_errorOccurred = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///Flag to track whether we've already called cleanup or not (with lock)
|
||||||
|
private let _cleanupCalledLock = DispatchSemaphore(value: 1)
|
||||||
|
private var _cleanupCalled: Bool = false
|
||||||
|
var cleanupCalled: Bool {
|
||||||
|
get {
|
||||||
|
_cleanupCalledLock.wait()
|
||||||
|
defer {
|
||||||
|
_cleanupCalledLock.signal()
|
||||||
|
}
|
||||||
|
return _cleanupCalled
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
_cleanupCalledLock.wait()
|
||||||
|
defer {
|
||||||
|
_cleanupCalledLock.signal()
|
||||||
|
}
|
||||||
|
_cleanupCalled = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Largest number of bytes we're willing to allocate for a Read
|
||||||
|
/// it's an anti-heartbleed-type paranoia check
|
||||||
|
private var maxReadLength: Int = 1048576
|
||||||
|
|
||||||
|
/// initializer
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - socket: thin PoCSocket wrapper around system calls
|
||||||
|
/// - parser: Manager of the CHTTPParser library
|
||||||
|
internal init(socket: PoCSocket, parser: StreamingParser, readQueue: DispatchQueue, writeQueue: DispatchQueue, maxReadLength: Int = 0) {
|
||||||
|
self.socket = socket
|
||||||
|
socketFD = socket.socketfd
|
||||||
|
socketReaderQueue = readQueue
|
||||||
|
socketWriterQueue = writeQueue
|
||||||
|
self.parser = parser
|
||||||
|
parser.parserConnector = self
|
||||||
|
if maxReadLength > 0 {
|
||||||
|
self.maxReadLength = maxReadLength
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if socket is still open. Used to decide whether it should be closed/pruned after timeout
|
||||||
|
public var isOpen: Bool {
|
||||||
|
return self.socket?.isOpen() ?? false
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Close the socket and free up memory unless we're in the middle of a request
|
||||||
|
func close() {
|
||||||
|
self.shouldShutdown = true
|
||||||
|
|
||||||
|
if !self.responseCompleted && !self.errorOccurred {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (self.socket?.socketfd ?? -1) > 0 {
|
||||||
|
self.socket?.shutdownAndClose()
|
||||||
|
}
|
||||||
|
|
||||||
|
// In a perfect world, we wouldn't have to clean this all up explicitly,
|
||||||
|
// but KDE/heaptrack informs us we're in far from a perfect world
|
||||||
|
|
||||||
|
if !(self.readerSource?.isCancelled ?? true) {
|
||||||
|
/*
|
||||||
|
OK, so later macOS wants `cancel()` to be called from inside the readerSource,
|
||||||
|
otherwise, there's a very intermittent thread-dependent crash, (ask me how I know)
|
||||||
|
so in that case, we set a Bool variable and call `activate()`. Older macOS doesn't
|
||||||
|
have `activate()` so we call back to calling `cancel()` directly.
|
||||||
|
|
||||||
|
Linux *DOES* have activate(), but it doesn't seem to do anything at present, so we call `cancel()`
|
||||||
|
directly in that case, too (Although I suspect that might need to change in future releases).
|
||||||
|
*/
|
||||||
|
#if os(Linux)
|
||||||
|
// Call Cancel directory on Linux
|
||||||
|
self.readerSource?.cancel()
|
||||||
|
self.cleanup()
|
||||||
|
#else
|
||||||
|
if #available(OSX 10.12, *) {
|
||||||
|
//Set Flag and Activate the readerSource so it can run `cancel()` for us
|
||||||
|
self.shouldShutdown = true
|
||||||
|
self.readerSource?.activate()
|
||||||
|
} else {
|
||||||
|
// Fallback on earlier versions
|
||||||
|
self.readerSource?.cancel()
|
||||||
|
self.cleanup()
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Called by the parser to let us know that it's done with this socket
|
||||||
|
public func closeWriter() {
|
||||||
|
self.socketWriterQueue.async { [weak self] in
|
||||||
|
if self?.readerSource?.isCancelled ?? true {
|
||||||
|
self?.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if the socket is idle, and if so, call close()
|
||||||
|
func closeIfIdleSocket() {
|
||||||
|
if !self.responseCompleted {
|
||||||
|
// We're in the middle of a connection - we're not idle
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let now = Date().timeIntervalSinceReferenceDate
|
||||||
|
if let keepAliveUntil = parser?.keepAliveUntil, now >= keepAliveUntil {
|
||||||
|
print("Closing idle socket \(socketFD)")
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func cleanup() {
|
||||||
|
guard !cleanupCalled else {
|
||||||
|
// This prevents a rare crash (~1 in 300,000) where cleanup is called from both reader and writer
|
||||||
|
// queues simultaneously
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//allow for memory to be reclaimed
|
||||||
|
if let strongReaderSource = self.readerSource {
|
||||||
|
strongReaderSource.setEventHandler(handler: nil)
|
||||||
|
strongReaderSource.setCancelHandler(handler: nil)
|
||||||
|
}
|
||||||
|
if let strongParser = self.parser {
|
||||||
|
strongParser.parserConnector = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanupCalled = true
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Called by the parser to let us know that a response has started being created
|
||||||
|
public func responseBeginning() {
|
||||||
|
self.responseCompleted = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Called by the parser to let us know that a response is complete, and we can close after timeout
|
||||||
|
public func responseComplete() {
|
||||||
|
self.responseCompleted = true
|
||||||
|
self.socketWriterQueue.async { [weak self] in
|
||||||
|
if self?.readerSource?.isCancelled ?? true {
|
||||||
|
self?.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Called by the parser to let us know that a response is complete and we should close the socket
|
||||||
|
public func responseCompleteCloseWriter() {
|
||||||
|
self.responseCompleted = true
|
||||||
|
self.socketWriterQueue.async { [weak self] in
|
||||||
|
self?.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Starts reading from the socket and feeding that data to the parser
|
||||||
|
public func process() {
|
||||||
|
let tempReaderSource: DispatchSourceRead
|
||||||
|
// Make sure we have a socket here. Don't use guard so that
|
||||||
|
// we don't encourage strongSocket to be used in the
|
||||||
|
// event handler, which could cause a leak
|
||||||
|
if let strongSocket = socket {
|
||||||
|
do {
|
||||||
|
try strongSocket.setBlocking(mode: true)
|
||||||
|
tempReaderSource = DispatchSource.makeReadSource(fileDescriptor: strongSocket.socketfd,
|
||||||
|
queue: socketReaderQueue)
|
||||||
|
self.readerSource = tempReaderSource
|
||||||
|
} catch {
|
||||||
|
print("Socket cannot be set to Blocking in process(): \(error)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print("Socket is nil in process()")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tempReaderSource.setEventHandler { [weak self] in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard strongSelf.socket?.socketfd ?? -1 > 0 else {
|
||||||
|
strongSelf.readerSource?.cancel()
|
||||||
|
strongSelf.cleanup()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard !strongSelf.shouldShutdown else {
|
||||||
|
strongSelf.readerSource?.cancel()
|
||||||
|
strongSelf.cleanup()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if let strongSocket = strongSelf.socket {
|
||||||
|
var length = 1 //initial value
|
||||||
|
do {
|
||||||
|
if strongSocket.socketfd > 0 {
|
||||||
|
var maxLength: Int = Int(strongSelf.readerSource?.data ?? 0)
|
||||||
|
if (maxLength > strongSelf.maxReadLength) || (maxLength <= 0) {
|
||||||
|
maxLength = strongSelf.maxReadLength
|
||||||
|
}
|
||||||
|
// make sure we read all data buffered by TLS layer
|
||||||
|
if (strongSocket.TLSdelegate != nil && (maxLength < TLSConstants.maxTLSRecordLength)) {
|
||||||
|
maxLength = TLSConstants.maxTLSRecordLength
|
||||||
|
}
|
||||||
|
var readBuffer: UnsafeMutablePointer<Int8> = UnsafeMutablePointer<Int8>.allocate(capacity: maxLength)
|
||||||
|
length = try strongSocket.socketRead(into: &readBuffer, maxLength:maxLength)
|
||||||
|
if length > 0 {
|
||||||
|
strongSelf.responseCompleted = false
|
||||||
|
|
||||||
|
let data = Data(bytes: readBuffer, count: length)
|
||||||
|
let numberParsed = strongSelf.parser?.readStream(data:data) ?? 0
|
||||||
|
|
||||||
|
defer {
|
||||||
|
readBuffer.deallocate(capacity: maxLength)
|
||||||
|
}
|
||||||
|
|
||||||
|
if numberParsed != data.count {
|
||||||
|
print("Error: wrong number of bytes consumed by parser (\(numberParsed) instead of \(data.count)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print("bad socket FD while reading")
|
||||||
|
length = -1
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
//print("ReaderSource Event Error: \(error)")
|
||||||
|
strongSelf.readerSource?.cancel()
|
||||||
|
|
||||||
|
strongSelf.errorOccurred = true
|
||||||
|
strongSelf.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
if length == 0 {
|
||||||
|
//print("ReaderSource Read count zero. Cancelling.")
|
||||||
|
strongSelf.readerSource?.cancel()
|
||||||
|
}
|
||||||
|
if length < 0 {
|
||||||
|
//print("ReaderSource Read count negative. Closing.")
|
||||||
|
strongSelf.errorOccurred = true
|
||||||
|
strongSelf.readerSource?.cancel()
|
||||||
|
strongSelf.close()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//print("ReaderSource Read found nil socket. Closing.")
|
||||||
|
strongSelf.errorOccurred = true
|
||||||
|
strongSelf.readerSource?.cancel()
|
||||||
|
strongSelf.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tempReaderSource.setCancelHandler { [weak self] in
|
||||||
|
if let strongSelf = self {
|
||||||
|
strongSelf.close() //close if we can
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
self.readerSource?.resume()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Called by the parser to give us data to send back out of the socket
|
||||||
|
///
|
||||||
|
/// - Parameter bytes: Data object to be queued to be written to the socket
|
||||||
|
public func queueSocketWrite(_ bytes: Data, completion:@escaping (Result) -> Void) {
|
||||||
|
self.socketWriterQueue.async { [weak self] in
|
||||||
|
self?.write(bytes)
|
||||||
|
completion(.ok)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Write data to a socket. Should be called in an `async` block on the `socketWriterQueue`
|
||||||
|
///
|
||||||
|
/// - Parameter data: data to be written
|
||||||
|
public func write(_ data: Data) {
|
||||||
|
do {
|
||||||
|
var written: Int = 0
|
||||||
|
var offset = 0
|
||||||
|
|
||||||
|
while written < data.count && !errorOccurred {
|
||||||
|
try data.withUnsafeBytes { (ptr: UnsafePointer<UInt8>) in
|
||||||
|
if let strongSocket = socket {
|
||||||
|
let result = try strongSocket.socketWrite(from: ptr + offset, bufSize:
|
||||||
|
data.count - offset)
|
||||||
|
if result < 0 {
|
||||||
|
//print("Received broken write socket indication")
|
||||||
|
errorOccurred = true
|
||||||
|
} else {
|
||||||
|
written += result
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//print("Socket unexpectedly nil during write")
|
||||||
|
errorOccurred = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
offset = data.count - written
|
||||||
|
}
|
||||||
|
if errorOccurred {
|
||||||
|
close()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
print("Received write socket error: \(error)")
|
||||||
|
errorOccurred = true
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+77
-60
@@ -8,31 +8,22 @@
|
|||||||
|
|
||||||
import Dispatch
|
import Dispatch
|
||||||
import Foundation
|
import Foundation
|
||||||
import HTTP
|
import ServerSecurity
|
||||||
|
import TLSService
|
||||||
import Socket
|
|
||||||
|
|
||||||
//import HeliumLogger
|
|
||||||
|
|
||||||
#if os(Linux)
|
|
||||||
import Signals
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// MARK: Server
|
// MARK: Server
|
||||||
|
|
||||||
/// An HTTP server that listens for connections on a TCP socket and spawns Listeners to handle them.
|
/// An HTTP server that listens for connections on a TCP socket and spawns Listeners to handle them.
|
||||||
public class BlueSocketSimpleServer : CurrentConnectionCounting {
|
///:nodoc:
|
||||||
|
public class PoCSocketSimpleServer: CurrentConnectionCounting {
|
||||||
|
/// PoCSocket to listen on for connections
|
||||||
/// Socket to listen on for connections
|
private let serverSocket: PoCSocket = PoCSocket()
|
||||||
private let serverSocket: Socket
|
|
||||||
|
|
||||||
/// Collection of listeners of sockets. Used to kill connections on timeout or shutdown
|
/// Collection of listeners of sockets. Used to kill connections on timeout or shutdown
|
||||||
private var connectionListenerList = ConnectionListenerCollection()
|
private var connectionListenerList = ConnectionListenerCollection()
|
||||||
|
|
||||||
// Timer that cleans up idle sockets on expire
|
/// 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
|
/// The port we're listening on. Used primarily to query a randomly assigned port during XCTests
|
||||||
public var port: Int {
|
public var port: Int {
|
||||||
@@ -40,45 +31,71 @@ public class BlueSocketSimpleServer : CurrentConnectionCounting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Tuning parameter to set the number of queues
|
/// 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
|
/// Tuning parameter to set the number of sockets we can accept at one time
|
||||||
private var acceptMax: Int
|
private var acceptMax: Int = 8 //sensible default
|
||||||
|
|
||||||
public init() {
|
/// Used to stop `accept(2)`ing while shutdown in progress to avoid spurious logs
|
||||||
#if os(Linux)
|
private let _isShuttingDownLock = DispatchSemaphore(value: 1)
|
||||||
Signals.trap(signal: .pipe) {
|
private var _isShuttingDown: Bool = false
|
||||||
_ in
|
var isShuttingDown: Bool {
|
||||||
print("Receiver closed socket, SIGPIPE ignored")
|
get {
|
||||||
|
_isShuttingDownLock.wait()
|
||||||
|
defer {
|
||||||
|
_isShuttingDownLock.signal()
|
||||||
}
|
}
|
||||||
#endif
|
return _isShuttingDown
|
||||||
|
}
|
||||||
serverSocket = try! Socket.create()
|
set {
|
||||||
pruneSocketTimer = DispatchSource.makeTimerSource(queue: DispatchQueue(label: "pruneSocketTimer"))
|
_isShuttingDownLock.wait()
|
||||||
queueMax = 4 //sensible default
|
defer {
|
||||||
acceptMax = 8 //sensible default
|
_isShuttingDownLock.signal()
|
||||||
|
}
|
||||||
|
_isShuttingDown = newValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Starts the server listening on a given port
|
/// Starts the server listening on a given port
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - port: TCP port. See listen(2)
|
/// - 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
|
/// - 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,
|
||||||
|
tls: TLSConfiguration? = nil,
|
||||||
|
handler: @escaping HTTPRequestHandler) throws {
|
||||||
|
|
||||||
|
// Don't let a signal generated by a broken socket kill the server
|
||||||
|
signal(SIGPIPE, SIG_IGN)
|
||||||
|
|
||||||
if queueCount > 0 {
|
if queueCount > 0 {
|
||||||
queueMax = queueCount
|
queueMax = queueCount
|
||||||
}
|
}
|
||||||
if acceptCount > 0 {
|
if acceptCount > 0 {
|
||||||
acceptMax = acceptCount
|
acceptMax = acceptCount
|
||||||
}
|
}
|
||||||
try self.serverSocket.listen(on: port, maxBacklogSize: 100)
|
// Set up TLS
|
||||||
|
if let tlsConfig = tls {
|
||||||
|
let tlsService = try TLSService(usingConfiguration: tlsConfig)
|
||||||
|
self.serverSocket.TLSdelegate = tlsService
|
||||||
|
}
|
||||||
|
try self.serverSocket.bindAndListen(on: port)
|
||||||
|
|
||||||
pruneSocketTimer.setEventHandler { [weak self] in
|
pruneSocketTimer.setEventHandler { [weak self] in
|
||||||
self?.connectionListenerList.prune()
|
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()
|
pruneSocketTimer.resume()
|
||||||
|
|
||||||
var readQueues = [DispatchQueue]()
|
var readQueues = [DispatchQueue]()
|
||||||
@@ -87,22 +104,28 @@ public class BlueSocketSimpleServer : CurrentConnectionCounting {
|
|||||||
|
|
||||||
let acceptSemaphore = DispatchSemaphore.init(value: acceptMax)
|
let acceptSemaphore = DispatchSemaphore.init(value: acceptMax)
|
||||||
|
|
||||||
for i in 0..<queueMax {
|
for idx in 0..<queueMax {
|
||||||
readQueues.append(DispatchQueue(label: "Read Queue \(i)"))
|
readQueues.append(DispatchQueue(label: "Read Queue \(idx)"))
|
||||||
writeQueues.append(DispatchQueue(label: "Write Queue \(i)"))
|
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
|
var listenerCount = 0
|
||||||
DispatchQueue.global().async {
|
DispatchQueue.global().async {
|
||||||
repeat {
|
repeat {
|
||||||
do {
|
do {
|
||||||
let clientSocket = try self.serverSocket.acceptClientConnection()
|
let acceptedClientSocket = try self.serverSocket.acceptClientConnection()
|
||||||
let streamingParser = StreamingParser(webapp: webapp, connectionCounter: self)
|
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 readQueue = readQueues[listenerCount % self.queueMax]
|
||||||
let writeQueue = writeQueues[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
|
listenerCount += 1
|
||||||
acceptSemaphore.wait()
|
acceptSemaphore.wait()
|
||||||
acceptQueue.async { [weak listener] in
|
acceptQueue.async { [weak listener] in
|
||||||
@@ -110,52 +133,46 @@ public class BlueSocketSimpleServer : CurrentConnectionCounting {
|
|||||||
acceptSemaphore.signal()
|
acceptSemaphore.signal()
|
||||||
}
|
}
|
||||||
self.connectionListenerList.add(listener)
|
self.connectionListenerList.add(listener)
|
||||||
|
|
||||||
} catch let error {
|
} catch let error {
|
||||||
print("Error accepting client connection: \(error)")
|
print("Error accepting client connection: \(error)")
|
||||||
}
|
}
|
||||||
} while self.serverSocket.isListening
|
} while !self.isShuttingDown && self.serverSocket.isListening
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Stop the server and close the sockets
|
/// Stop the server and close the sockets
|
||||||
public func stop() {
|
public func stop() {
|
||||||
|
isShuttingDown = true
|
||||||
connectionListenerList.closeAll()
|
connectionListenerList.closeAll()
|
||||||
serverSocket.close()
|
serverSocket.shutdownAndClose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Count the connections - can be used in XCTests
|
/// Count the connections - can be used in XCTests
|
||||||
public var connectionCount: Int {
|
public var connectionCount: Int {
|
||||||
return connectionListenerList.count
|
return connectionListenerList.count
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Collection of ConnectionListeners, wrapped with weak references, so the memory can be freed when the socket closes
|
/// Collection of ConnectionListeners, wrapped with weak references, so the memory can be freed when the socket closes
|
||||||
class ConnectionListenerCollection {
|
class ConnectionListenerCollection {
|
||||||
|
|
||||||
/// Weak wrapper class
|
/// Weak wrapper class
|
||||||
class WeakConnectionListener<T: AnyObject> {
|
class WeakConnectionListener<T: AnyObject> {
|
||||||
weak var value : T?
|
weak var value: T?
|
||||||
init (_ value: T) {
|
init (_ value: T) {
|
||||||
self.value = value
|
self.value = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let lock = DispatchSemaphore(value: 1)
|
/// Lock around access to storage
|
||||||
|
private let lock = DispatchSemaphore(value: 1)
|
||||||
|
|
||||||
/// Storage for weak connection listeners
|
/// Storage for weak connection listeners
|
||||||
var storage = [WeakConnectionListener<BlueSocketConnectionListener>]()
|
private var storage = [WeakConnectionListener<PoCSocketConnectionListener>]()
|
||||||
|
|
||||||
|
|
||||||
/// Add a new connection to the collection
|
/// Add a new connection to the collection
|
||||||
///
|
///
|
||||||
/// - Parameter listener: socket manager object
|
/// - Parameter listener: socket manager object
|
||||||
func add(_ listener:BlueSocketConnectionListener) {
|
func add(_ listener: PoCSocketConnectionListener) {
|
||||||
lock.wait()
|
lock.wait()
|
||||||
storage.append(WeakConnectionListener(listener))
|
storage.append(WeakConnectionListener(listener))
|
||||||
lock.signal()
|
lock.signal()
|
||||||
@@ -164,7 +181,7 @@ class ConnectionListenerCollection {
|
|||||||
/// Used when shutting down the server to close all connections
|
/// Used when shutting down the server to close all connections
|
||||||
func closeAll() {
|
func closeAll() {
|
||||||
lock.wait()
|
lock.wait()
|
||||||
storage.filter { nil != $0.value }.forEach { $0.value?.close() }
|
storage.filter { $0.value != nil }.forEach { $0.value?.close() }
|
||||||
lock.signal()
|
lock.signal()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,15 +189,15 @@ class ConnectionListenerCollection {
|
|||||||
func prune() {
|
func prune() {
|
||||||
lock.wait()
|
lock.wait()
|
||||||
storage.filter { nil != $0.value }.forEach { $0.value?.closeIfIdleSocket() }
|
storage.filter { nil != $0.value }.forEach { $0.value?.closeIfIdleSocket() }
|
||||||
storage = storage.filter { nil != $0.value }.filter { $0.value?.isOpen ?? false}
|
storage = storage.filter { $0.value != nil }.filter { $0.value?.isOpen ?? false }
|
||||||
lock.signal()
|
lock.signal()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Count of collections
|
/// Count of collections
|
||||||
var count: Int {
|
var count: Int {
|
||||||
lock.wait()
|
lock.wait()
|
||||||
let c = storage.filter { nil != $0.value }.count
|
let count = storage.filter { $0.value != nil }.count
|
||||||
lock.signal()
|
lock.signal()
|
||||||
return c
|
return count
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,350 +0,0 @@
|
|||||||
// This source file is part of the Swift.org Server APIs open source project
|
|
||||||
//
|
|
||||||
// Copyright (c) 2017 Swift Server API project authors
|
|
||||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
||||||
//
|
|
||||||
// See http://swift.org/LICENSE.txt for license information
|
|
||||||
//
|
|
||||||
|
|
||||||
import XCTest
|
|
||||||
|
|
||||||
@testable import HTTP
|
|
||||||
@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 resolver = TestResponseResolver(request: request, requestBody: Data())
|
|
||||||
resolver.resolveHandler(EchoWebApp().serve)
|
|
||||||
XCTAssertNotNil(resolver.response)
|
|
||||||
XCTAssertNotNil(resolver.responseBody)
|
|
||||||
XCTAssertEqual(HTTPResponseStatus.ok.code, resolver.response?.status.code ?? 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testEcho() {
|
|
||||||
let testString="This is a test"
|
|
||||||
let request = HTTPRequest(method: .post, target:"/echo", httpVersion: HTTPVersion(major: 1, minor: 1), headers: ["X-foo": "bar"])
|
|
||||||
let resolver = TestResponseResolver(request: request, requestBody: testString.data(using: .utf8)!)
|
|
||||||
resolver.resolveHandler(EchoWebApp().serve)
|
|
||||||
XCTAssertNotNil(resolver.response)
|
|
||||||
XCTAssertNotNil(resolver.responseBody)
|
|
||||||
XCTAssertEqual(HTTPResponseStatus.ok.code, resolver.response?.status.code ?? 0)
|
|
||||||
XCTAssertEqual(testString, resolver.responseBody?.withUnsafeBytes { String(bytes: $0, encoding: .utf8) } ?? "Nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
func testHello() {
|
|
||||||
let request = HTTPRequest(method: .get, target:"/helloworld", httpVersion: HTTPVersion(major: 1, minor: 1), headers: ["X-foo": "bar"])
|
|
||||||
let resolver = TestResponseResolver(request: request, requestBody: Data())
|
|
||||||
resolver.resolveHandler(HelloWorldWebApp().serve)
|
|
||||||
XCTAssertNotNil(resolver.response)
|
|
||||||
XCTAssertNotNil(resolver.responseBody)
|
|
||||||
XCTAssertEqual(HTTPResponseStatus.ok.code, resolver.response?.status.code ?? 0)
|
|
||||||
XCTAssertEqual("Hello, World!", resolver.responseBody?.withUnsafeBytes { String(bytes: $0, encoding: .utf8) } ?? "Nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
func testSimpleHello() {
|
|
||||||
let request = HTTPRequest(method: .get, target:"/helloworld", httpVersion: HTTPVersion(major: 1, minor: 1), headers: ["X-foo": "bar"])
|
|
||||||
let resolver = TestResponseResolver(request: request, requestBody: Data())
|
|
||||||
let simpleHelloWebApp = SimpleResponseCreator { (request, body) -> SimpleResponseCreator.Response in
|
|
||||||
return SimpleResponseCreator.Response(
|
|
||||||
status: .ok,
|
|
||||||
headers: ["X-foo": "bar"],
|
|
||||||
body: "Hello, World!".data(using: .utf8)!
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
resolver.resolveHandler(simpleHelloWebApp.serve)
|
|
||||||
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()
|
|
||||||
do {
|
|
||||||
try server.start(port: 0, webapp: OkWebApp().serve)
|
|
||||||
let session = URLSession(configuration: URLSessionConfiguration.default)
|
|
||||||
let url = URL(string: "http://localhost:\(server.port)/")!
|
|
||||||
print("Test \(#function) on port \(server.port)")
|
|
||||||
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
|
||||||
let response = rawResponse as? HTTPURLResponse
|
|
||||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
|
||||||
XCTAssertNotNil(response)
|
|
||||||
XCTAssertNotNil(responseBody)
|
|
||||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
|
||||||
receivedExpectation.fulfill()
|
|
||||||
}
|
|
||||||
dataTask.resume()
|
|
||||||
self.waitForExpectations(timeout: 10) { (error) in
|
|
||||||
if let error = error {
|
|
||||||
XCTFail("\(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
server.stop()
|
|
||||||
} catch {
|
|
||||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func testHelloEndToEnd() {
|
|
||||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
|
||||||
|
|
||||||
let server = BlueSocketSimpleServer()
|
|
||||||
do {
|
|
||||||
try server.start(port: 0, webapp: HelloWorldWebApp().serve)
|
|
||||||
let session = URLSession(configuration: URLSessionConfiguration.default)
|
|
||||||
let url = URL(string: "http://localhost:\(server.port)/helloworld")!
|
|
||||||
print("Test \(#function) on port \(server.port)")
|
|
||||||
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
|
||||||
let response = rawResponse as? HTTPURLResponse
|
|
||||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
|
||||||
XCTAssertNotNil(response)
|
|
||||||
XCTAssertNotNil(responseBody)
|
|
||||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
|
||||||
XCTAssertEqual("Hello, World!", String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
|
||||||
receivedExpectation.fulfill()
|
|
||||||
}
|
|
||||||
dataTask.resume()
|
|
||||||
self.waitForExpectations(timeout: 10) { (error) in
|
|
||||||
if let error = error {
|
|
||||||
XCTFail("\(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
server.stop()
|
|
||||||
} catch {
|
|
||||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func testSimpleHelloEndToEnd() {
|
|
||||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
|
||||||
let simpleHelloWebApp = SimpleResponseCreator { (request, body) -> SimpleResponseCreator.Response in
|
|
||||||
return SimpleResponseCreator.Response(
|
|
||||||
status: .ok,
|
|
||||||
headers: ["X-foo": "bar"],
|
|
||||||
body: "Hello, World!".data(using: .utf8)!
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
let server = BlueSocketSimpleServer()
|
|
||||||
do {
|
|
||||||
try server.start(port: 0, webapp: simpleHelloWebApp.serve)
|
|
||||||
} 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)")
|
|
||||||
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
|
||||||
print("\(#function) dataTask returned")
|
|
||||||
let response = rawResponse as? HTTPURLResponse
|
|
||||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
|
||||||
XCTAssertNotNil(response)
|
|
||||||
XCTAssertNotNil(responseBody)
|
|
||||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
|
||||||
let responseString = String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil"
|
|
||||||
XCTAssertEqual("Hello, World!", responseString)
|
|
||||||
print("\(#function) fulfilling expectation")
|
|
||||||
receivedExpectation.fulfill()
|
|
||||||
}
|
|
||||||
dataTask.resume()
|
|
||||||
self.waitForExpectations(timeout: 10) { (error) in
|
|
||||||
if let error = error {
|
|
||||||
XCTFail("\(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
server.stop()
|
|
||||||
print("\(#function) stopping server")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func testRequestEchoEndToEnd() {
|
|
||||||
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
|
||||||
let testString="This is a test"
|
|
||||||
|
|
||||||
let server = BlueSocketSimpleServer()
|
|
||||||
do {
|
|
||||||
try server.start(port: 0, webapp: EchoWebApp().serve)
|
|
||||||
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"
|
|
||||||
request.httpBody = testString.data(using: .utf8)
|
|
||||||
request.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
|
||||||
|
|
||||||
let dataTask = session.dataTask(with: request) { (responseBody, rawResponse, error) in
|
|
||||||
let response = rawResponse as? HTTPURLResponse
|
|
||||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
|
||||||
XCTAssertNotNil(response)
|
|
||||||
XCTAssertNotNil(responseBody)
|
|
||||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
|
||||||
XCTAssertEqual(testString, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
|
||||||
receivedExpectation.fulfill()
|
|
||||||
}
|
|
||||||
dataTask.resume()
|
|
||||||
self.waitForExpectations(timeout: 10) { (error) in
|
|
||||||
if let error = error {
|
|
||||||
XCTFail("\(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
server.stop()
|
|
||||||
} catch {
|
|
||||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func testRequestKeepAliveEchoEndToEnd() {
|
|
||||||
let receivedExpectation1 = self.expectation(description: "Received web response 1: \(#function)")
|
|
||||||
let receivedExpectation2 = self.expectation(description: "Received web response 2: \(#function)")
|
|
||||||
let receivedExpectation3 = self.expectation(description: "Received web response 3: \(#function)")
|
|
||||||
let testString1="This is a test"
|
|
||||||
let testString2="This is a test, too"
|
|
||||||
let testString3="This is also a test"
|
|
||||||
|
|
||||||
let server = BlueSocketSimpleServer()
|
|
||||||
do {
|
|
||||||
try server.start(port: 0, webapp: EchoWebApp().serve)
|
|
||||||
let session = URLSession(configuration: URLSessionConfiguration.default)
|
|
||||||
let url = URL(string: "http://localhost:\(server.port)/echo")!
|
|
||||||
print("Test \(#function) on port \(server.port)")
|
|
||||||
var request1 = URLRequest(url: url)
|
|
||||||
request1.httpMethod = "POST"
|
|
||||||
request1.httpBody = testString1.data(using: .utf8)
|
|
||||||
request1.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
|
||||||
|
|
||||||
let dataTask1 = session.dataTask(with: request1) { (responseBody, rawResponse, error) in
|
|
||||||
let response = rawResponse as? HTTPURLResponse
|
|
||||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
|
||||||
XCTAssertNotNil(response)
|
|
||||||
let headers = response?.allHeaderFields ?? ["":""]
|
|
||||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
|
||||||
let keepAliveHeader = headers["Keep-Alive"]
|
|
||||||
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")
|
|
||||||
var request2 = URLRequest(url: url)
|
|
||||||
request2.httpMethod = "POST"
|
|
||||||
request2.httpBody = testString2.data(using: .utf8)
|
|
||||||
request2.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
|
||||||
let dataTask2 = session.dataTask(with: request2) { (responseBody2, rawResponse2, error2) in
|
|
||||||
let response2 = rawResponse2 as? HTTPURLResponse
|
|
||||||
XCTAssertNil(error2, "\(error2!.localizedDescription)")
|
|
||||||
XCTAssertNotNil(response2)
|
|
||||||
let headers = response2?.allHeaderFields ?? ["":""]
|
|
||||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
|
||||||
let keepAliveHeader = headers["Keep-Alive"]
|
|
||||||
XCTAssertEqual(connectionHeader,"Keep-Alive","No Keep-Alive Connection")
|
|
||||||
XCTAssertNotNil(keepAliveHeader,"No Keep-Alive Header")
|
|
||||||
XCTAssertEqual(server.connectionCount, 1)
|
|
||||||
XCTAssertNotNil(responseBody2)
|
|
||||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response2?.statusCode ?? 0)
|
|
||||||
XCTAssertEqual(testString2, String(data: responseBody2 ?? Data(), encoding: .utf8) ?? "Nil")
|
|
||||||
var request3 = URLRequest(url: url)
|
|
||||||
request3.httpMethod = "POST"
|
|
||||||
request3.httpBody = testString3.data(using: .utf8)
|
|
||||||
request3.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
|
||||||
let dataTask3 = session.dataTask(with: request3) { (responseBody, rawResponse, error) in
|
|
||||||
let response = rawResponse as? HTTPURLResponse
|
|
||||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
|
||||||
XCTAssertNotNil(response)
|
|
||||||
let headers = response?.allHeaderFields ?? ["":""]
|
|
||||||
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
|
||||||
let keepAliveHeader = headers["Keep-Alive"]
|
|
||||||
XCTAssertEqual(connectionHeader,"Keep-Alive","No Keep-Alive Connection")
|
|
||||||
XCTAssertNotNil(keepAliveHeader,"No Keep-Alive Header")
|
|
||||||
XCTAssertEqual(server.connectionCount, 1)
|
|
||||||
XCTAssertNotNil(responseBody)
|
|
||||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
|
||||||
XCTAssertEqual(testString3, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
|
||||||
receivedExpectation3.fulfill()
|
|
||||||
}
|
|
||||||
dataTask3.resume()
|
|
||||||
receivedExpectation2.fulfill()
|
|
||||||
}
|
|
||||||
dataTask2.resume()
|
|
||||||
receivedExpectation1.fulfill()
|
|
||||||
}
|
|
||||||
dataTask1.resume()
|
|
||||||
|
|
||||||
self.waitForExpectations(timeout: 10) { (error) in
|
|
||||||
if let error = error {
|
|
||||||
XCTFail("\(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//server.stop()
|
|
||||||
} catch {
|
|
||||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func 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)
|
|
||||||
|
|
||||||
var testDataLong = testExecutableData + testExecutableData + testExecutableData + testExecutableData
|
|
||||||
let length = testDataLong.count
|
|
||||||
let keep = 16385
|
|
||||||
let remove = length - keep
|
|
||||||
if (remove > 0) {
|
|
||||||
testDataLong.removeLast(remove)
|
|
||||||
}
|
|
||||||
|
|
||||||
let testData = Data(testDataLong)
|
|
||||||
|
|
||||||
let server = BlueSocketSimpleServer()
|
|
||||||
do {
|
|
||||||
try server.start(port: 0, webapp: EchoWebApp().serve)
|
|
||||||
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"
|
|
||||||
request.httpBody = testData
|
|
||||||
let dataTask = session.dataTask(with: request) { (responseBody, rawResponse, error) in
|
|
||||||
let response = rawResponse as? HTTPURLResponse
|
|
||||||
XCTAssertNil(error, "\(error!.localizedDescription)")
|
|
||||||
XCTAssertNotNil(response)
|
|
||||||
XCTAssertNotNil(responseBody)
|
|
||||||
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
|
||||||
XCTAssertEqual(testData, responseBody ?? Data())
|
|
||||||
receivedExpectation.fulfill()
|
|
||||||
}
|
|
||||||
dataTask.resume()
|
|
||||||
self.waitForExpectations(timeout: 10) { (error) in
|
|
||||||
if let error = error {
|
|
||||||
XCTFail("\(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
server.stop()
|
|
||||||
} catch {
|
|
||||||
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static var allTests = [
|
|
||||||
("testEcho", testEcho),
|
|
||||||
("testHello", testHello),
|
|
||||||
("testSimpleHello", testSimpleHello),
|
|
||||||
("testResponseOK", testResponseOK),
|
|
||||||
("testOkEndToEnd", testOkEndToEnd),
|
|
||||||
("testHelloEndToEnd", testHelloEndToEnd),
|
|
||||||
("testSimpleHelloEndToEnd", testSimpleHelloEndToEnd),
|
|
||||||
("testRequestEchoEndToEnd", testRequestEchoEndToEnd),
|
|
||||||
("testRequestKeepAliveEchoEndToEnd", testRequestKeepAliveEchoEndToEnd),
|
|
||||||
("testRequestLargeEchoEndToEnd", testRequestLargeEchoEndToEnd),
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -43,40 +43,40 @@ class HeadersTests: XCTestCase {
|
|||||||
])
|
])
|
||||||
|
|
||||||
headers = HTTPHeaders()
|
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)
|
XCTAssertEqual(0, initialCount)
|
||||||
|
|
||||||
headers.append(["Test-Header": "Test Value"])
|
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)
|
XCTAssertEqual(1, nextCount)
|
||||||
|
|
||||||
let testHeaderValueArray = headers[valuesFor: "test-header"]
|
let testHeaderValueArray = headers[valuesFor: "test-header"]
|
||||||
XCTAssertNotNil(testHeaderValueArray)
|
XCTAssertNotNil(testHeaderValueArray)
|
||||||
XCTAssertEqual(1,testHeaderValueArray.count)
|
XCTAssertEqual(1, testHeaderValueArray.count)
|
||||||
XCTAssertEqual("Test Value",testHeaderValueArray.first ?? "Not Found")
|
XCTAssertEqual("Test Value", testHeaderValueArray.first ?? "Not Found")
|
||||||
|
|
||||||
headers.append(["Test-header": "Test Value 2"])
|
headers.append(["Test-header": "Test Value 2"])
|
||||||
let testHeaderValueArray2 = headers[valuesFor: "test-header"]
|
let testHeaderValueArray2 = headers[valuesFor: "test-header"]
|
||||||
XCTAssertNotNil(testHeaderValueArray2)
|
XCTAssertNotNil(testHeaderValueArray2)
|
||||||
XCTAssertEqual(2,testHeaderValueArray2.count)
|
XCTAssertEqual(2, testHeaderValueArray2.count)
|
||||||
XCTAssertEqual("Test Value",testHeaderValueArray2.first ?? "Not Found")
|
XCTAssertEqual("Test Value", testHeaderValueArray2.first ?? "Not Found")
|
||||||
let testHeaderValueArray2Remainder = testHeaderValueArray2.dropFirst()
|
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
|
//This should overwrites, since the subscript is documented to use lowercase keys
|
||||||
headers[valuesFor: "TEST-HEADER"]=["Test Value 3"]
|
headers[valuesFor: "TEST-HEADER"]=["Test Value 3"]
|
||||||
let testHeaderValueArray3 = headers[valuesFor: "test-header"]
|
let testHeaderValueArray3 = headers[valuesFor: "test-header"]
|
||||||
XCTAssertNotNil(testHeaderValueArray3)
|
XCTAssertNotNil(testHeaderValueArray3)
|
||||||
XCTAssertEqual(1,testHeaderValueArray3.count)
|
XCTAssertEqual(1, testHeaderValueArray3.count)
|
||||||
|
|
||||||
//Overwrite
|
//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"]
|
let testHeaderValueArray4 = headers[valuesFor: "test-header"]
|
||||||
XCTAssertNotNil(testHeaderValueArray4)
|
XCTAssertNotNil(testHeaderValueArray4)
|
||||||
XCTAssertEqual(2,testHeaderValueArray4.count)
|
XCTAssertEqual(2, testHeaderValueArray4.count)
|
||||||
XCTAssertEqual("Test Value 4a",testHeaderValueArray4.first ?? "Not Found")
|
XCTAssertEqual("Test Value 4a", testHeaderValueArray4.first ?? "Not Found")
|
||||||
let testHeaderValueArray4Remainder = testHeaderValueArray4.dropFirst()
|
let testHeaderValueArray4Remainder = testHeaderValueArray4.dropFirst()
|
||||||
XCTAssertEqual("Test Value 4b",testHeaderValueArray4Remainder.first ?? "Not Found")
|
XCTAssertEqual("Test Value 4b", testHeaderValueArray4Remainder.first ?? "Not Found")
|
||||||
}
|
}
|
||||||
|
|
||||||
static var allTests = [
|
static var allTests = [
|
||||||
|
|||||||
@@ -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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-8
@@ -9,23 +9,22 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import HTTP
|
import HTTP
|
||||||
|
|
||||||
|
/// Simple `HTTPRequestHandler` that just echoes back whatever input it gets
|
||||||
/// Simple `WebApp` that just echoes back whatever input it gets
|
class EchoHandler: HTTPRequestHandling {
|
||||||
class EchoWebApp: WebAppContaining {
|
func handle(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||||
func serve(req: HTTPRequest, res: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
|
||||||
//Assume the router gave us the right request - at least for now
|
//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
|
return .processBody { (chunk, stop) in
|
||||||
switch chunk {
|
switch chunk {
|
||||||
case .chunk(let data, let finishedProcessing):
|
case .chunk(let data, let finishedProcessing):
|
||||||
res.writeBody(data) { _ in
|
response.writeBody(data) { _ in
|
||||||
finishedProcessing()
|
finishedProcessing()
|
||||||
}
|
}
|
||||||
case .end:
|
case .end:
|
||||||
res.done()
|
response.done()
|
||||||
default:
|
default:
|
||||||
stop = true /* don't call us anymore */
|
stop = true /* don't call us anymore */
|
||||||
res.abort()
|
response.abort()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-7
@@ -9,21 +9,21 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import HTTP
|
import HTTP
|
||||||
|
|
||||||
/// Simple `WebApp` that prints "Hello, World" as per K&R
|
/// Simple `HTTPRequestHandler` that prints "Hello, World" as per K&R
|
||||||
class HelloWorldWebApp: WebAppContaining {
|
class HelloWorldHandler: HTTPRequestHandling {
|
||||||
func serve(req: HTTPRequest, res: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
func handle(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||||
//Assume the router gave us the right request - at least for now
|
//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
|
return .processBody { (chunk, stop) in
|
||||||
switch chunk {
|
switch chunk {
|
||||||
case .chunk(_, let finishedProcessing):
|
case .chunk(_, let finishedProcessing):
|
||||||
finishedProcessing()
|
finishedProcessing()
|
||||||
case .end:
|
case .end:
|
||||||
res.writeBody("Hello, World!")
|
response.writeBody("Hello, World!")
|
||||||
res.done()
|
response.done()
|
||||||
default:
|
default:
|
||||||
stop = true /* don't call us anymore */
|
stop = true /* don't call us anymore */
|
||||||
res.abort()
|
response.abort()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-7
@@ -9,11 +9,11 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import HTTP
|
import HTTP
|
||||||
|
|
||||||
/// `HelloWorldWebApp` that sets the keep alive header for XCTest purposes
|
/// `HelloWorldRequestHandler` that sets the keep alive header for XCTest purposes
|
||||||
class HelloWorldKeepAliveWebApp: WebAppContaining {
|
class HelloWorldKeepAliveHandler: HTTPRequestHandling {
|
||||||
func serve(req: HTTPRequest, res: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
func handle(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||||
//Assume the router gave us the right request - at least for now
|
//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",
|
"Transfer-Encoding": "chunked",
|
||||||
"Connection": "Keep-Alive",
|
"Connection": "Keep-Alive",
|
||||||
"Keep-Alive": "timeout=5, max=10",
|
"Keep-Alive": "timeout=5, max=10",
|
||||||
@@ -23,11 +23,11 @@ class HelloWorldKeepAliveWebApp: WebAppContaining {
|
|||||||
case .chunk(_, let finishedProcessing):
|
case .chunk(_, let finishedProcessing):
|
||||||
finishedProcessing()
|
finishedProcessing()
|
||||||
case .end:
|
case .end:
|
||||||
res.writeBody("Hello, World!")
|
response.writeBody("Hello, World!")
|
||||||
res.done()
|
response.done()
|
||||||
default:
|
default:
|
||||||
stop = true /* don't call us anymore */
|
stop = true /* don't call us anymore */
|
||||||
res.abort()
|
response.abort()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-4
@@ -9,11 +9,11 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import HTTP
|
import HTTP
|
||||||
|
|
||||||
/// Simple `WebApp` that returns 200: OK without a body
|
/// Simple `HTTPRequestHandler` that returns 200: OK without a body
|
||||||
class OkWebApp: WebAppContaining {
|
class OkHandler: HTTPRequestHandling {
|
||||||
func serve(req: HTTPRequest, res: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
func handle(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||||
//Assume the router gave us the right request - at least for now
|
//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
|
return .discardBody
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+12
-14
@@ -7,17 +7,15 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
This file isn't part of the API per se, but it's the easiest way to get started - just supply a completion block.
|
||||||
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.
|
||||||
It's also really handy for building up `WebApp`s to use when writing tests.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import HTTP
|
import HTTP
|
||||||
|
|
||||||
/// Simple block-based wrapper to create a `WebApp`. Normally used during XCTests
|
/// Simple block-based wrapper to create a `HTTPRequestHandler`. Normally used during XCTests
|
||||||
public class SimpleResponseCreator: WebAppContaining {
|
public class SimpleResponseCreator: HTTPRequestHandling {
|
||||||
|
|
||||||
public struct Response {
|
public struct Response {
|
||||||
public let status: HTTPResponseStatus
|
public let status: HTTPResponseStatus
|
||||||
@@ -34,25 +32,25 @@ public class SimpleResponseCreator: WebAppContaining {
|
|||||||
|
|
||||||
var buffer = Data()
|
var buffer = Data()
|
||||||
|
|
||||||
public func serve(req: HTTPRequest, res: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
public func handle(request: HTTPRequest, response: HTTPResponseWriter ) -> HTTPBodyProcessing {
|
||||||
return .processBody { (chunk, stop) in
|
return .processBody { (chunk, stop) in
|
||||||
switch chunk {
|
switch chunk {
|
||||||
case .chunk(let data, let finishedProcessing):
|
case .chunk(let data, let finishedProcessing):
|
||||||
if (data.count > 0) {
|
if data.count > 0 {
|
||||||
self.buffer.append(Data(data))
|
self.buffer.append(Data(data))
|
||||||
}
|
}
|
||||||
finishedProcessing()
|
finishedProcessing()
|
||||||
case .end:
|
case .end:
|
||||||
let response = self.completionHandler(req, self.buffer)
|
let responseResult = self.completionHandler(request, self.buffer)
|
||||||
var headers = response.headers
|
var headers = responseResult.headers
|
||||||
headers.replace([.transferEncoding: "chunked"])
|
headers.replace([.transferEncoding: "chunked"])
|
||||||
res.writeHeader(status: response.status, headers: headers)
|
response.writeHeader(status: responseResult.status, headers: headers)
|
||||||
res.writeBody(response.body) { _ in
|
response.writeBody(responseResult.body) { _ in
|
||||||
res.done()
|
response.done()
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
stop = true /* don't call us anymore */
|
stop = true /* don't call us anymore */
|
||||||
res.abort()
|
response.abort()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+35
-14
@@ -18,28 +18,50 @@ class TestResponseResolver: HTTPResponseWriter {
|
|||||||
var response: (status: HTTPResponseStatus, headers: HTTPHeaders)?
|
var response: (status: HTTPResponseStatus, headers: HTTPHeaders)?
|
||||||
var responseBody: HTTPResponseBody?
|
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) {
|
init(request: HTTPRequest, requestBody: Data) {
|
||||||
self.request = request
|
self.request = request
|
||||||
self.requestBody = requestBody.withUnsafeBytes { (ptr: UnsafePointer<UInt8>) -> DispatchData in
|
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)
|
let chunkHandler = handler(request, self)
|
||||||
var stop=false
|
if shouldStopProcessingBody {
|
||||||
var finished=false
|
return
|
||||||
while !stop && !finished {
|
}
|
||||||
switch chunkHandler {
|
switch chunkHandler {
|
||||||
case .processBody(let handler):
|
case .processBody(let handler):
|
||||||
handler(.chunk(data: self.requestBody, finishedProcessing: {
|
_shouldStopProcessingBodyLock.wait()
|
||||||
finished=true
|
handler(.chunk(data: self.requestBody, finishedProcessing: { self._shouldStopProcessingBodyLock.signal() }), &_shouldStopProcessingBody)
|
||||||
}), &stop)
|
var dummy = false
|
||||||
handler(.end, &stop)
|
handler(.end, &dummy)
|
||||||
case .discardBody:
|
case .discardBody:
|
||||||
finished=true
|
break
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,12 +87,11 @@ class TestResponseResolver: HTTPResponseWriter {
|
|||||||
completion(.ok)
|
completion(.ok)
|
||||||
}
|
}
|
||||||
func done() /* convenience */ {
|
func done() /* convenience */ {
|
||||||
done() { _ in
|
done { _ in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func abort() {
|
func abort() {
|
||||||
fatalError("abort called, not sure what to do with it")
|
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() {
|
func testOkay() {
|
||||||
let okay = HTTPResponseStatus.ok
|
let okay = HTTPResponseStatus.ok
|
||||||
XCTAssertEqual(200,okay.code)
|
XCTAssertEqual(200, okay.code)
|
||||||
XCTAssertEqual("OK",okay.reasonPhrase)
|
XCTAssertEqual("OK", okay.reasonPhrase)
|
||||||
XCTAssertEqual("\(okay)", "200 OK")
|
XCTAssertEqual("\(okay)", "200 OK")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testContinue() {
|
func testContinue() {
|
||||||
XCTAssertEqual("Continue",HTTPResponseStatus.continue.reasonPhrase)
|
XCTAssertEqual("Continue", HTTPResponseStatus.continue.reasonPhrase)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testNotFound() {
|
func testNotFound() {
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
// This source file is part of the Swift.org Server APIs open source project
|
||||||
|
//
|
||||||
|
// Copyright (c) 2017 Swift Server API project authors
|
||||||
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||||
|
//
|
||||||
|
// See http://swift.org/LICENSE.txt for license information
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
import Dispatch
|
||||||
|
|
||||||
|
@testable import HTTP
|
||||||
|
|
||||||
|
class ServerTests: XCTestCase {
|
||||||
|
func testResponseOK() {
|
||||||
|
let request = HTTPRequest(method: .get, target: "/echo", httpVersion: HTTPVersion(major: 1, minor: 1), headers: ["X-foo": "bar"])
|
||||||
|
let resolver = TestResponseResolver(request: request, requestBody: Data())
|
||||||
|
resolver.resolveHandler(EchoHandler().handle)
|
||||||
|
XCTAssertNotNil(resolver.response)
|
||||||
|
XCTAssertNotNil(resolver.responseBody)
|
||||||
|
XCTAssertEqual(HTTPResponseStatus.ok.code, resolver.response?.status.code ?? 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testEcho() {
|
||||||
|
let testString = "This is a test"
|
||||||
|
let request = HTTPRequest(method: .post, target: "/echo", httpVersion: HTTPVersion(major: 1, minor: 1), headers: ["X-foo": "bar"])
|
||||||
|
let resolver = TestResponseResolver(request: request, requestBody: testString.data(using: .utf8)!)
|
||||||
|
resolver.resolveHandler(EchoHandler().handle)
|
||||||
|
XCTAssertNotNil(resolver.response)
|
||||||
|
XCTAssertNotNil(resolver.responseBody)
|
||||||
|
XCTAssertEqual(HTTPResponseStatus.ok.code, resolver.response?.status.code ?? 0)
|
||||||
|
XCTAssertEqual(testString, resolver.responseBody?.withUnsafeBytes { String(bytes: $0, encoding: .utf8) } ?? "Nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
func testHello() {
|
||||||
|
let request = HTTPRequest(method: .get, target: "/helloworld", httpVersion: HTTPVersion(major: 1, minor: 1), headers: ["X-foo": "bar"])
|
||||||
|
let resolver = TestResponseResolver(request: request, requestBody: Data())
|
||||||
|
resolver.resolveHandler(HelloWorldHandler().handle)
|
||||||
|
XCTAssertNotNil(resolver.response)
|
||||||
|
XCTAssertNotNil(resolver.responseBody)
|
||||||
|
XCTAssertEqual(HTTPResponseStatus.ok.code, resolver.response?.status.code ?? 0)
|
||||||
|
XCTAssertEqual("Hello, World!", resolver.responseBody?.withUnsafeBytes { String(bytes: $0, encoding: .utf8) } ?? "Nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
func testSimpleHello() {
|
||||||
|
let request = HTTPRequest(method: .get, target: "/helloworld", httpVersion: HTTPVersion(major: 1, minor: 1), headers: ["X-foo": "bar"])
|
||||||
|
let resolver = TestResponseResolver(request: request, requestBody: Data())
|
||||||
|
let simpleHelloWebApp = SimpleResponseCreator { (_, body) -> SimpleResponseCreator.Response in
|
||||||
|
return SimpleResponseCreator.Response(
|
||||||
|
status: .ok,
|
||||||
|
headers: ["X-foo": "bar"],
|
||||||
|
body: "Hello, World!".data(using: .utf8)!
|
||||||
|
)
|
||||||
|
}
|
||||||
|
resolver.resolveHandler(simpleHelloWebApp.handle)
|
||||||
|
XCTAssertNotNil(resolver.response)
|
||||||
|
XCTAssertNotNil(resolver.responseBody)
|
||||||
|
XCTAssertEqual(HTTPResponseStatus.ok.code, resolver.response?.status.code ?? 0)
|
||||||
|
XCTAssertEqual("Hello, World!", resolver.responseBody?.withUnsafeBytes { String(bytes: $0, encoding: .utf8) } ?? "Nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
static var allTests = [
|
||||||
|
("testEcho", testEcho),
|
||||||
|
("testHello", testHello),
|
||||||
|
("testSimpleHello", testSimpleHello),
|
||||||
|
("testResponseOK", testResponseOK),
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,494 @@
|
|||||||
|
// This source file is part of the Swift.org Server APIs open source project
|
||||||
|
//
|
||||||
|
// Copyright (c) 2017 Swift Server API project authors
|
||||||
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||||
|
//
|
||||||
|
// See http://swift.org/LICENSE.txt for license information
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
import Dispatch
|
||||||
|
|
||||||
|
@testable import HTTP
|
||||||
|
|
||||||
|
class ServerTestsEndToEnd: XCTestCase {
|
||||||
|
func testOkEndToEnd() {
|
||||||
|
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||||
|
|
||||||
|
let options = HTTPServer.Options(onPort: 0)
|
||||||
|
let server = HTTPServer(with: options, requestHandler: OkHandler().handle)
|
||||||
|
do {
|
||||||
|
try server.start()
|
||||||
|
let session = URLSession(configuration: .default)
|
||||||
|
let url = URL(string: "http://localhost:\(server.port)/")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
receivedExpectation.fulfill()
|
||||||
|
}
|
||||||
|
dataTask.resume()
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testHelloEndToEnd() {
|
||||||
|
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||||
|
|
||||||
|
let options = HTTPServer.Options(onPort: 0)
|
||||||
|
let server = HTTPServer(with: options, requestHandler: HelloWorldHandler().handle)
|
||||||
|
do {
|
||||||
|
try server.start()
|
||||||
|
let session = URLSession(configuration: .default)
|
||||||
|
let url = URL(string: "http://localhost:\(server.port)/helloworld")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual("Hello, World!", String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
receivedExpectation.fulfill()
|
||||||
|
}
|
||||||
|
dataTask.resume()
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testSimpleHelloEndToEnd() {
|
||||||
|
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||||
|
let simpleHelloWebApp = SimpleResponseCreator { (_, body) -> SimpleResponseCreator.Response in
|
||||||
|
return SimpleResponseCreator.Response(
|
||||||
|
status: .ok,
|
||||||
|
headers: ["X-foo": "bar"],
|
||||||
|
body: "Hello, World!".data(using: .utf8)!
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
let options = HTTPServer.Options(onPort: 0)
|
||||||
|
let server = HTTPServer(with: options, requestHandler: simpleHelloWebApp.handle)
|
||||||
|
do {
|
||||||
|
try server.start()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
|
||||||
|
let session = URLSession(configuration: .default)
|
||||||
|
let url = URL(string: "http://localhost:\(server.port)/helloworld")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
||||||
|
print("\(#function) dataTask returned")
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
let responseString = String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil"
|
||||||
|
XCTAssertEqual("Hello, World!", responseString)
|
||||||
|
print("\(#function) fulfilling expectation")
|
||||||
|
receivedExpectation.fulfill()
|
||||||
|
}
|
||||||
|
dataTask.resume()
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
print("\(#function) stopping server")
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRequestEchoEndToEnd() {
|
||||||
|
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||||
|
let testString="This is a test"
|
||||||
|
|
||||||
|
let options = HTTPServer.Options(onPort: 0)
|
||||||
|
let server = HTTPServer(with: options, requestHandler: EchoHandler().handle)
|
||||||
|
do {
|
||||||
|
try server.start()
|
||||||
|
let session = URLSession(configuration: .default)
|
||||||
|
let url = URL(string: "http://localhost:\(server.port)/echo")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
var request = URLRequest(url: url)
|
||||||
|
request.httpMethod = "POST"
|
||||||
|
request.httpBody = testString.data(using: .utf8)
|
||||||
|
request.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||||
|
|
||||||
|
let dataTask = session.dataTask(with: request) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testString, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
receivedExpectation.fulfill()
|
||||||
|
}
|
||||||
|
dataTask.resume()
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRequestKeepAliveEchoEndToEnd() {
|
||||||
|
let receivedExpectation1 = self.expectation(description: "Received web response 1: \(#function)")
|
||||||
|
let receivedExpectation2 = self.expectation(description: "Received web response 2: \(#function)")
|
||||||
|
let receivedExpectation3 = self.expectation(description: "Received web response 3: \(#function)")
|
||||||
|
let testString1="This is a test"
|
||||||
|
let testString2="This is a test, too"
|
||||||
|
let testString3="This is also a test"
|
||||||
|
|
||||||
|
let options = HTTPServer.Options(onPort: 0)
|
||||||
|
let server = HTTPServer(with: options, requestHandler: EchoHandler().handle)
|
||||||
|
do {
|
||||||
|
try server.start()
|
||||||
|
let session = URLSession(configuration: .default)
|
||||||
|
let url = URL(string: "http://localhost:\(server.port)/echo")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
var request1 = URLRequest(url: url)
|
||||||
|
request1.httpMethod = "POST"
|
||||||
|
request1.httpBody = testString1.data(using: .utf8)
|
||||||
|
request1.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||||
|
|
||||||
|
let dataTask1 = session.dataTask(with: request1) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
let headers = response?.allHeaderFields ?? ["": ""]
|
||||||
|
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||||
|
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||||
|
XCTAssertNotNil(responseBody, "No Response Body")
|
||||||
|
XCTAssertEqual(server.connectionCount, 1)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testString1, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
var request2 = URLRequest(url: url)
|
||||||
|
request2.httpMethod = "POST"
|
||||||
|
request2.httpBody = testString2.data(using: .utf8)
|
||||||
|
request2.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||||
|
let dataTask2 = session.dataTask(with: request2) { (responseBody2, rawResponse2, error2) in
|
||||||
|
let response2 = rawResponse2 as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error2, "\(error2!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response2)
|
||||||
|
let headers = response2?.allHeaderFields ?? ["": ""]
|
||||||
|
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||||
|
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||||
|
XCTAssertEqual(server.connectionCount, 1)
|
||||||
|
XCTAssertNotNil(responseBody2)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response2?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testString2, String(data: responseBody2 ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
var request3 = URLRequest(url: url)
|
||||||
|
request3.httpMethod = "POST"
|
||||||
|
request3.httpBody = testString3.data(using: .utf8)
|
||||||
|
request3.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||||
|
let dataTask3 = session.dataTask(with: request3) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
let headers = response?.allHeaderFields ?? ["": ""]
|
||||||
|
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||||
|
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||||
|
XCTAssertEqual(server.connectionCount, 1)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testString3, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
receivedExpectation3.fulfill()
|
||||||
|
}
|
||||||
|
dataTask3.resume()
|
||||||
|
receivedExpectation2.fulfill()
|
||||||
|
}
|
||||||
|
dataTask2.resume()
|
||||||
|
receivedExpectation1.fulfill()
|
||||||
|
}
|
||||||
|
dataTask1.resume()
|
||||||
|
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMultipleRequestWithoutKeepAliveEchoEndToEnd() {
|
||||||
|
let receivedExpectation1 = self.expectation(description: "Received web response 1: \(#function)")
|
||||||
|
let receivedExpectation2 = self.expectation(description: "Received web response 2: \(#function)")
|
||||||
|
let receivedExpectation3 = self.expectation(description: "Received web response 3: \(#function)")
|
||||||
|
let testString1="This is a test"
|
||||||
|
let testString2="This is a test, too"
|
||||||
|
let testString3="This is also a test"
|
||||||
|
|
||||||
|
let options = HTTPServer.Options(onPort: 0)
|
||||||
|
let server = HTTPServer(with: options, requestHandler: EchoHandler().handle)
|
||||||
|
do {
|
||||||
|
try server.start()
|
||||||
|
let session = URLSession(configuration: .default)
|
||||||
|
let url1 = URL(string: "http://localhost:\(server.port)/echo")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
var request1 = URLRequest(url: url1)
|
||||||
|
request1.httpMethod = "POST"
|
||||||
|
request1.httpBody = testString1.data(using: .utf8)
|
||||||
|
request1.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||||
|
|
||||||
|
let dataTask1 = session.dataTask(with: request1) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
let headers = response?.allHeaderFields ?? ["": ""]
|
||||||
|
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||||
|
let keepAliveHeader = headers["Connection"]
|
||||||
|
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||||
|
XCTAssertNotNil(keepAliveHeader)
|
||||||
|
XCTAssertNotNil(responseBody, "No Keep-Alive Header")
|
||||||
|
XCTAssertEqual(server.connectionCount, 1)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testString1, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
let url2 = URL(string: "http://127.0.0.1:\(server.port)/echo")!
|
||||||
|
var request2 = URLRequest(url: url2)
|
||||||
|
request2.httpMethod = "POST"
|
||||||
|
request2.httpBody = testString2.data(using: .utf8)
|
||||||
|
request2.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||||
|
request2.setValue("close", forHTTPHeaderField: "Connection")
|
||||||
|
let dataTask2 = session.dataTask(with: request2) { (responseBody2, rawResponse2, error2) in
|
||||||
|
let response2 = rawResponse2 as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error2, "\(error2!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response2)
|
||||||
|
let headers = response2?.allHeaderFields ?? ["": ""]
|
||||||
|
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||||
|
let keepAliveHeader = headers["Connection"]
|
||||||
|
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||||
|
XCTAssertNotNil(keepAliveHeader, "No Keep-Alive Header")
|
||||||
|
XCTAssertEqual(server.connectionCount, 2)
|
||||||
|
XCTAssertNotNil(responseBody2)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response2?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testString2, String(data: responseBody2 ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
let url3 = URL(string: "http://0.0.0.0:\(server.port)/echo")!
|
||||||
|
var request3 = URLRequest(url: url3)
|
||||||
|
request3.httpMethod = "POST"
|
||||||
|
request3.httpBody = testString3.data(using: .utf8)
|
||||||
|
request3.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||||
|
request3.setValue("close", forHTTPHeaderField: "Connection")
|
||||||
|
let dataTask3 = session.dataTask(with: request3) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
let headers = response?.allHeaderFields ?? ["": ""]
|
||||||
|
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||||
|
let keepAliveHeader = headers["Connection"]
|
||||||
|
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||||
|
XCTAssertNotNil(keepAliveHeader, "No Keep-Alive Header")
|
||||||
|
XCTAssertEqual(server.connectionCount, 3)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testString3, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
receivedExpectation3.fulfill()
|
||||||
|
}
|
||||||
|
dataTask3.resume()
|
||||||
|
receivedExpectation2.fulfill()
|
||||||
|
}
|
||||||
|
dataTask2.resume()
|
||||||
|
receivedExpectation1.fulfill()
|
||||||
|
}
|
||||||
|
dataTask1.resume()
|
||||||
|
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRequestLargeEchoEndToEnd() {
|
||||||
|
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||||
|
|
||||||
|
//Use a small chunk size to make sure that we're testing multiple HTTPBodyHandler calls
|
||||||
|
let chunkSize = 1024
|
||||||
|
|
||||||
|
// Get a file we know exists
|
||||||
|
let executableURL = URL(fileURLWithPath: CommandLine.arguments[0])
|
||||||
|
let testExecutableData: Data
|
||||||
|
|
||||||
|
do {
|
||||||
|
testExecutableData = try Data(contentsOf: executableURL)
|
||||||
|
} catch {
|
||||||
|
XCTFail("Could not create Data from contents of \(executableURL)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var testDataLong = testExecutableData + testExecutableData + testExecutableData + testExecutableData
|
||||||
|
let length = testDataLong.count
|
||||||
|
let keep = 16385
|
||||||
|
let remove = length - keep
|
||||||
|
if remove > 0 {
|
||||||
|
testDataLong.removeLast(remove)
|
||||||
|
}
|
||||||
|
|
||||||
|
let testData = Data(testDataLong)
|
||||||
|
|
||||||
|
let server = PoCSocketSimpleServer()
|
||||||
|
do {
|
||||||
|
try server.start(port: 0, maxReadLength: chunkSize, handler: EchoHandler().handle)
|
||||||
|
let session = URLSession(configuration: .default)
|
||||||
|
let url = URL(string: "http://localhost:\(server.port)/echo")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
var request = URLRequest(url: url)
|
||||||
|
request.httpMethod = "POST"
|
||||||
|
request.httpBody = testData
|
||||||
|
let dataTask = session.dataTask(with: request) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testData, responseBody ?? Data())
|
||||||
|
receivedExpectation.fulfill()
|
||||||
|
}
|
||||||
|
dataTask.resume()
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRequestLargePostHelloWorld() {
|
||||||
|
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||||
|
|
||||||
|
//Use a small chunk size to make sure that we stop after one HTTPBodyHandler call
|
||||||
|
let chunkSize = 1024
|
||||||
|
|
||||||
|
// Get a file we know exists
|
||||||
|
let executableURL = URL(fileURLWithPath: CommandLine.arguments[0])
|
||||||
|
let testExecutableData: Data
|
||||||
|
|
||||||
|
do {
|
||||||
|
testExecutableData = try Data(contentsOf: executableURL)
|
||||||
|
} catch {
|
||||||
|
XCTFail("Could not create Data from contents of \(executableURL)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//Make sure there's data there
|
||||||
|
XCTAssertNotNil(testExecutableData)
|
||||||
|
|
||||||
|
let executableLength = testExecutableData.count
|
||||||
|
|
||||||
|
let server = PoCSocketSimpleServer()
|
||||||
|
do {
|
||||||
|
let testHandler = AbortAndSendHelloHandler()
|
||||||
|
try server.start(port: 0, maxReadLength: chunkSize, handler: testHandler.handle)
|
||||||
|
let session = URLSession(configuration: .default)
|
||||||
|
let url = URL(string: "http://localhost:\(server.port)/echo")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
var request = URLRequest(url: url)
|
||||||
|
request.httpMethod = "POST"
|
||||||
|
let uploadTask = session.uploadTask(with: request, fromFile: executableURL) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual("Hello, World!", String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
XCTAssertEqual(Int(testHandler.chunkCalledCount), 1)
|
||||||
|
XCTAssertLessThan(testHandler.chunkLength, executableLength, "Should have written less than the length of the file")
|
||||||
|
XCTAssertLessThanOrEqual(Int(testHandler.chunkLength), chunkSize)
|
||||||
|
receivedExpectation.fulfill()
|
||||||
|
}
|
||||||
|
uploadTask.resume()
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testExplicitCloseConnections() {
|
||||||
|
let expectation = self.expectation(description: "0 Open Connection")
|
||||||
|
let server = PoCSocketSimpleServer()
|
||||||
|
let keepAliveTimeout = 0.1
|
||||||
|
|
||||||
|
do {
|
||||||
|
try server.start(port: 0, keepAliveTimeout: keepAliveTimeout, handler: OkHandler().handle)
|
||||||
|
|
||||||
|
let session = URLSession(configuration: .default)
|
||||||
|
let url1 = URL(string: "http://localhost:\(server.port)")!
|
||||||
|
var request = URLRequest(url: url1)
|
||||||
|
request.httpMethod = "POST"
|
||||||
|
request.setValue("close", forHTTPHeaderField: "Connection")
|
||||||
|
|
||||||
|
let dataTask1 = session.dataTask(with: request) { (_, _, error) in
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
#if os(Linux)
|
||||||
|
XCTAssertEqual(server.connectionCount, 0)
|
||||||
|
expectation.fulfill()
|
||||||
|
|
||||||
|
// Darwin's URLSession replaces the `Connection: close` header with `Connection: keep-alive`, so allow it to expire
|
||||||
|
#else
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + keepAliveTimeout) {
|
||||||
|
XCTAssertEqual(server.connectionCount, 0)
|
||||||
|
expectation.fulfill()
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
dataTask1.resume()
|
||||||
|
|
||||||
|
self.waitForExpectations(timeout: 30) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static var allTests = [
|
||||||
|
("testOkEndToEnd", testOkEndToEnd),
|
||||||
|
("testHelloEndToEnd", testHelloEndToEnd),
|
||||||
|
("testSimpleHelloEndToEnd", testSimpleHelloEndToEnd),
|
||||||
|
("testRequestEchoEndToEnd", testRequestEchoEndToEnd),
|
||||||
|
("testRequestKeepAliveEchoEndToEnd", testRequestKeepAliveEchoEndToEnd),
|
||||||
|
("testRequestLargeEchoEndToEnd", testRequestLargeEchoEndToEnd),
|
||||||
|
("testExplicitCloseConnections", testExplicitCloseConnections),
|
||||||
|
("testRequestLargePostHelloWorld", testRequestLargePostHelloWorld),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,572 @@
|
|||||||
|
// This source file is part of the Swift.org Server APIs open source project
|
||||||
|
//
|
||||||
|
// Copyright (c) 2017 Swift Server API project authors
|
||||||
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||||
|
//
|
||||||
|
// See http://swift.org/LICENSE.txt for license information
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
import Dispatch
|
||||||
|
import ServerSecurity
|
||||||
|
|
||||||
|
@testable import HTTP
|
||||||
|
|
||||||
|
class TLSServerTests: XCTestCase {
|
||||||
|
|
||||||
|
func testOkEndToEndTLSwithCA() {
|
||||||
|
let config = createCASignedTLSConfig()
|
||||||
|
testOkEndToEndInternal(config: config, selfsigned: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testOkEndToEndTLSwithSelfSigned() {
|
||||||
|
let config = createSelfSignedTLSConfig()
|
||||||
|
testOkEndToEndInternal(config: config, selfsigned: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testOkEndToEndInternal(config: TLSConfiguration, selfsigned: Bool) {
|
||||||
|
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||||
|
let urlStr: String
|
||||||
|
let session: URLSession
|
||||||
|
|
||||||
|
let server = HTTPServer(with: HTTPServer.Options(onPort: 0, tlsConf: config), requestHandler: OkHandler().handle)
|
||||||
|
do {
|
||||||
|
try server.start()
|
||||||
|
|
||||||
|
if selfsigned {
|
||||||
|
#if os(OSX)
|
||||||
|
session = URLSession(configuration: URLSessionConfiguration.default, delegate: self, delegateQueue:OperationQueue.main)
|
||||||
|
#else
|
||||||
|
// delegate in URLSession in Linux is not implemented. Using this to compile but it will fail if run on Linux.
|
||||||
|
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||||
|
#endif
|
||||||
|
urlStr = "localhost"
|
||||||
|
|
||||||
|
} else {
|
||||||
|
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||||
|
urlStr = "ssl.gelareh.xyz"
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = URL(string: "https://\(urlStr):\(server.port)/")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
print("url = \(url.absoluteString) ")
|
||||||
|
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
receivedExpectation.fulfill()
|
||||||
|
}
|
||||||
|
dataTask.resume()
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testHelloEndToEndTLSwithCA() {
|
||||||
|
let config = createCASignedTLSConfig()
|
||||||
|
testHelloEndToEndInternal(config: config, selfsigned: false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testHelloEndToEndTLSwithSelfSigned() {
|
||||||
|
let config = createSelfSignedTLSConfig()
|
||||||
|
testHelloEndToEndInternal(config: config, selfsigned: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testHelloEndToEndInternal(config: TLSConfiguration, selfsigned: Bool) {
|
||||||
|
|
||||||
|
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||||
|
let urlStr: String
|
||||||
|
let session: URLSession
|
||||||
|
|
||||||
|
let server = HTTPServer(with: HTTPServer.Options(onPort: 0, tlsConf: config), requestHandler: HelloWorldHandler().handle)
|
||||||
|
do {
|
||||||
|
try server.start()
|
||||||
|
|
||||||
|
if selfsigned {
|
||||||
|
#if os(OSX)
|
||||||
|
session = URLSession(configuration: URLSessionConfiguration.default, delegate: self, delegateQueue:OperationQueue.main)
|
||||||
|
#else
|
||||||
|
// delegate in URLSession in Linux is not implemented. Using this to compile but it will fail if run on Linux.
|
||||||
|
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||||
|
#endif
|
||||||
|
urlStr = "localhost"
|
||||||
|
|
||||||
|
} else {
|
||||||
|
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||||
|
urlStr = "ssl.gelareh.xyz"
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = URL(string: "https://\(urlStr):\(server.port)/helloworld")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual("Hello, World!", String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
receivedExpectation.fulfill()
|
||||||
|
}
|
||||||
|
dataTask.resume()
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testSimpleHelloEndToEndTLSwithCA() {
|
||||||
|
let config = createCASignedTLSConfig()
|
||||||
|
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||||
|
let session: URLSession
|
||||||
|
|
||||||
|
let simpleHelloWebApp = SimpleResponseCreator { (_, body) -> SimpleResponseCreator.Response in
|
||||||
|
return SimpleResponseCreator.Response(
|
||||||
|
status: .ok,
|
||||||
|
headers: ["X-foo": "bar"],
|
||||||
|
body: "Hello, World!".data(using: .utf8)!
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
let server = HTTPServer(with: HTTPServer.Options(onPort: 0, tlsConf: config), requestHandler: simpleHelloWebApp.handle)
|
||||||
|
do {
|
||||||
|
try server.start()
|
||||||
|
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||||
|
|
||||||
|
let url = URL(string: "https://ssl.gelareh.xyz:\(server.port)/helloworld")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
let dataTask = session.dataTask(with: url) { (responseBody, rawResponse, error) in
|
||||||
|
print("\(#function) dataTask returned")
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
let responseString = String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil"
|
||||||
|
XCTAssertEqual("Hello, World!", responseString)
|
||||||
|
print("\(#function) fulfilling expectation")
|
||||||
|
receivedExpectation.fulfill()
|
||||||
|
}
|
||||||
|
dataTask.resume()
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRequestEchoEndToEndTLSwithCA() {
|
||||||
|
let config = createCASignedTLSConfig()
|
||||||
|
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||||
|
let session: URLSession
|
||||||
|
let testString = "This is a test"
|
||||||
|
|
||||||
|
let server = HTTPServer(with: HTTPServer.Options(onPort: 0, tlsConf: config), requestHandler: EchoHandler().handle)
|
||||||
|
do {
|
||||||
|
try server.start()
|
||||||
|
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||||
|
|
||||||
|
let url = URL(string: "https://ssl.gelareh.xyz:\(server.port)/echo")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
var request = URLRequest(url: url)
|
||||||
|
request.httpMethod = "POST"
|
||||||
|
request.httpBody = testString.data(using: .utf8)
|
||||||
|
request.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||||
|
|
||||||
|
let dataTask = session.dataTask(with: request) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testString, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
receivedExpectation.fulfill()
|
||||||
|
}
|
||||||
|
dataTask.resume()
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRequestKeepAliveEchoEndToEndTLSwithCA() {
|
||||||
|
let config = createCASignedTLSConfig()
|
||||||
|
let receivedExpectation1 = self.expectation(description: "Received web response 1: \(#function)")
|
||||||
|
let receivedExpectation2 = self.expectation(description: "Received web response 2: \(#function)")
|
||||||
|
let receivedExpectation3 = self.expectation(description: "Received web response 3: \(#function)")
|
||||||
|
let testString1="This is a test"
|
||||||
|
let testString2="This is a test, too"
|
||||||
|
let testString3="This is also a test"
|
||||||
|
let session: URLSession
|
||||||
|
|
||||||
|
let server = HTTPServer(with: HTTPServer.Options(onPort: 0, tlsConf: config), requestHandler: EchoHandler().handle)
|
||||||
|
do {
|
||||||
|
try server.start()
|
||||||
|
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||||
|
|
||||||
|
let url = URL(string: "https://ssl.gelareh.xyz:\(server.port)/echo")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
var request1 = URLRequest(url: url)
|
||||||
|
request1.httpMethod = "POST"
|
||||||
|
request1.httpBody = testString1.data(using: .utf8)
|
||||||
|
request1.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||||
|
|
||||||
|
let dataTask1 = session.dataTask(with: request1) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
let headers = response?.allHeaderFields ?? ["": ""]
|
||||||
|
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||||
|
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||||
|
XCTAssertNotNil(responseBody, "No Response Body")
|
||||||
|
XCTAssertEqual(server.connectionCount, 1)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testString1, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
var request2 = URLRequest(url: url)
|
||||||
|
request2.httpMethod = "POST"
|
||||||
|
request2.httpBody = testString2.data(using: .utf8)
|
||||||
|
request2.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||||
|
let dataTask2 = session.dataTask(with: request2) { (responseBody2, rawResponse2, error2) in
|
||||||
|
let response2 = rawResponse2 as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error2, "\(error2!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response2)
|
||||||
|
let headers = response2?.allHeaderFields ?? ["": ""]
|
||||||
|
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||||
|
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||||
|
XCTAssertEqual(server.connectionCount, 1)
|
||||||
|
XCTAssertNotNil(responseBody2)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response2?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testString2, String(data: responseBody2 ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
var request3 = URLRequest(url: url)
|
||||||
|
request3.httpMethod = "POST"
|
||||||
|
request3.httpBody = testString3.data(using: .utf8)
|
||||||
|
request3.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||||
|
let dataTask3 = session.dataTask(with: request3) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
let headers = response?.allHeaderFields ?? ["": ""]
|
||||||
|
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||||
|
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||||
|
XCTAssertEqual(server.connectionCount, 1)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testString3, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
receivedExpectation3.fulfill()
|
||||||
|
}
|
||||||
|
dataTask3.resume()
|
||||||
|
receivedExpectation2.fulfill()
|
||||||
|
}
|
||||||
|
dataTask2.resume()
|
||||||
|
receivedExpectation1.fulfill()
|
||||||
|
}
|
||||||
|
dataTask1.resume()
|
||||||
|
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMultipleRequestWithoutKeepAliveEchoEndToEndTLSwithCA() {
|
||||||
|
let config = createCASignedTLSConfig()
|
||||||
|
let receivedExpectation1 = self.expectation(description: "Received web response 1: \(#function)")
|
||||||
|
let receivedExpectation2 = self.expectation(description: "Received web response 2: \(#function)")
|
||||||
|
let receivedExpectation3 = self.expectation(description: "Received web response 3: \(#function)")
|
||||||
|
let testString1="This is a test"
|
||||||
|
let testString2="This is a test, too"
|
||||||
|
let testString3="This is also a test"
|
||||||
|
let session: URLSession
|
||||||
|
|
||||||
|
let server = HTTPServer(with: HTTPServer.Options(onPort: 0, tlsConf: config), requestHandler: EchoHandler().handle)
|
||||||
|
do {
|
||||||
|
try server.start()
|
||||||
|
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||||
|
|
||||||
|
let url1 = URL(string: "https://ssl.gelareh.xyz:\(server.port)/echo")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
var request1 = URLRequest(url: url1)
|
||||||
|
request1.httpMethod = "POST"
|
||||||
|
request1.httpBody = testString1.data(using: .utf8)
|
||||||
|
request1.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||||
|
request1.setValue("Keep-Alive", forHTTPHeaderField: "Connection")
|
||||||
|
|
||||||
|
let dataTask1 = session.dataTask(with: request1) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
let headers = response?.allHeaderFields ?? ["": ""]
|
||||||
|
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||||
|
let keepAliveHeader = headers["Connection"]
|
||||||
|
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||||
|
XCTAssertNotNil(keepAliveHeader)
|
||||||
|
XCTAssertNotNil(responseBody, "No Keep-Alive Header")
|
||||||
|
XCTAssertEqual(server.connectionCount, 1)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testString1, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
let url2 = URL(string: "https://ssl1.gelareh.xyz:\(server.port)/echo")!
|
||||||
|
var request2 = URLRequest(url: url2)
|
||||||
|
request2.httpMethod = "POST"
|
||||||
|
request2.httpBody = testString2.data(using: .utf8)
|
||||||
|
request2.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||||
|
request2.setValue("Keep-Alive", forHTTPHeaderField: "Connection")
|
||||||
|
let dataTask2 = session.dataTask(with: request2) { (responseBody2, rawResponse2, error2) in
|
||||||
|
let response2 = rawResponse2 as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error2, "\(error2!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response2)
|
||||||
|
let headers = response2?.allHeaderFields ?? ["": ""]
|
||||||
|
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||||
|
let keepAliveHeader = headers["Connection"]
|
||||||
|
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||||
|
XCTAssertNotNil(keepAliveHeader, "No Keep-Alive Header")
|
||||||
|
XCTAssertEqual(server.connectionCount, 2)
|
||||||
|
XCTAssertNotNil(responseBody2)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response2?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testString2, String(data: responseBody2 ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
let url3 = URL(string: "https://ssl2.gelareh.xyz:\(server.port)/echo")!
|
||||||
|
var request3 = URLRequest(url: url3)
|
||||||
|
request3.httpMethod = "POST"
|
||||||
|
request3.httpBody = testString3.data(using: .utf8)
|
||||||
|
request3.setValue("text/plain", forHTTPHeaderField: "Content-Type")
|
||||||
|
request3.setValue("Keep-Alive", forHTTPHeaderField: "Connection")
|
||||||
|
let dataTask3 = session.dataTask(with: request3) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
let headers = response?.allHeaderFields ?? ["": ""]
|
||||||
|
let connectionHeader: String = headers["Connection"] as? String ?? ""
|
||||||
|
let keepAliveHeader = headers["Connection"]
|
||||||
|
XCTAssertEqual(connectionHeader, "Keep-Alive", "No Keep-Alive Connection")
|
||||||
|
XCTAssertNotNil(keepAliveHeader, "No Keep-Alive Header")
|
||||||
|
XCTAssertEqual(server.connectionCount, 3)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testString3, String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
receivedExpectation3.fulfill()
|
||||||
|
}
|
||||||
|
dataTask3.resume()
|
||||||
|
receivedExpectation2.fulfill()
|
||||||
|
}
|
||||||
|
dataTask2.resume()
|
||||||
|
receivedExpectation1.fulfill()
|
||||||
|
}
|
||||||
|
dataTask1.resume()
|
||||||
|
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRequestLargeEchoEndToEndTLSwithCA() {
|
||||||
|
let config = createCASignedTLSConfig()
|
||||||
|
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||||
|
let session: URLSession
|
||||||
|
|
||||||
|
//Use a small chunk size to make sure that we're testing multiple HTTPBodyHandler calls
|
||||||
|
let chunkSize = 1024
|
||||||
|
|
||||||
|
// Get a file we know exists
|
||||||
|
let executableURL = URL(fileURLWithPath: CommandLine.arguments[0])
|
||||||
|
let testExecutableData: Data
|
||||||
|
|
||||||
|
do {
|
||||||
|
testExecutableData = try Data(contentsOf: executableURL)
|
||||||
|
} catch {
|
||||||
|
XCTFail("Could not create Data from contents of \(executableURL)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var testDataLong = testExecutableData + testExecutableData + testExecutableData + testExecutableData
|
||||||
|
let length = testDataLong.count
|
||||||
|
let keep = 16385
|
||||||
|
let remove = length - keep
|
||||||
|
if remove > 0 {
|
||||||
|
testDataLong.removeLast(remove)
|
||||||
|
}
|
||||||
|
|
||||||
|
let testData = Data(testDataLong)
|
||||||
|
|
||||||
|
let server = PoCSocketSimpleServer()
|
||||||
|
do {
|
||||||
|
try server.start(port: 0, maxReadLength: chunkSize, tls: config, handler: EchoHandler().handle)
|
||||||
|
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||||
|
|
||||||
|
let url = URL(string: "https://ssl.gelareh.xyz:\(server.port)/echo")!
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
var request = URLRequest(url: url)
|
||||||
|
request.httpMethod = "POST"
|
||||||
|
request.httpBody = testData
|
||||||
|
let dataTask = session.dataTask(with: request) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual(testData, responseBody ?? Data())
|
||||||
|
receivedExpectation.fulfill()
|
||||||
|
}
|
||||||
|
dataTask.resume()
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testRequestLargePostHelloWorldTLSwithCA() {
|
||||||
|
let config = createCASignedTLSConfig()
|
||||||
|
let receivedExpectation = self.expectation(description: "Received web response \(#function)")
|
||||||
|
let session: URLSession
|
||||||
|
|
||||||
|
// Use a small chunk size to make sure that we stop after one HTTPBodyHandler call
|
||||||
|
let chunkSize = 1024
|
||||||
|
|
||||||
|
// Get a file we know exists
|
||||||
|
let executableURL = URL(fileURLWithPath: CommandLine.arguments[0])
|
||||||
|
let testExecutableData: Data
|
||||||
|
|
||||||
|
do {
|
||||||
|
testExecutableData = try Data(contentsOf: executableURL)
|
||||||
|
} catch {
|
||||||
|
XCTFail("Could not create Data from contents of \(executableURL)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//Make sure there's data there
|
||||||
|
XCTAssertNotNil(testExecutableData)
|
||||||
|
|
||||||
|
let executableLength = testExecutableData.count
|
||||||
|
|
||||||
|
let server = PoCSocketSimpleServer()
|
||||||
|
do {
|
||||||
|
let testHandler = AbortAndSendHelloHandler()
|
||||||
|
try server.start(port: 0, maxReadLength: chunkSize, tls: config, handler: testHandler.handle)
|
||||||
|
session = URLSession(configuration: URLSessionConfiguration.default)
|
||||||
|
print("Test \(#function) on port \(server.port)")
|
||||||
|
|
||||||
|
let url = URL(string: "https://ssl.gelareh.xyz:\(server.port)/echo")!
|
||||||
|
var request = URLRequest(url: url)
|
||||||
|
request.httpMethod = "POST"
|
||||||
|
let uploadTask = session.uploadTask(with: request, fromFile: executableURL) { (responseBody, rawResponse, error) in
|
||||||
|
let response = rawResponse as? HTTPURLResponse
|
||||||
|
XCTAssertNil(error, "\(error!.localizedDescription)")
|
||||||
|
XCTAssertNotNil(response)
|
||||||
|
XCTAssertNotNil(responseBody)
|
||||||
|
XCTAssertEqual(Int(HTTPResponseStatus.ok.code), response?.statusCode ?? 0)
|
||||||
|
XCTAssertEqual("Hello, World!", String(data: responseBody ?? Data(), encoding: .utf8) ?? "Nil")
|
||||||
|
XCTAssertEqual(Int(testHandler.chunkCalledCount), 1)
|
||||||
|
XCTAssertLessThan(testHandler.chunkLength, executableLength, "Should have written less than the length of the file")
|
||||||
|
if (chunkSize < TLSConstants.maxTLSRecordLength) {
|
||||||
|
XCTAssertLessThanOrEqual(Int(testHandler.chunkLength), TLSConstants.maxTLSRecordLength)
|
||||||
|
} else {
|
||||||
|
XCTAssertLessThanOrEqual(Int(testHandler.chunkLength), chunkSize)
|
||||||
|
}
|
||||||
|
receivedExpectation.fulfill()
|
||||||
|
}
|
||||||
|
uploadTask.resume()
|
||||||
|
self.waitForExpectations(timeout: 10) { (error) in
|
||||||
|
if let error = error {
|
||||||
|
XCTFail("\(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.stop()
|
||||||
|
} catch {
|
||||||
|
XCTFail("Error listening on port \(0): \(error). Use server.failed(callback:) to handle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func createSelfSignedTLSConfig() -> TLSConfiguration {
|
||||||
|
#if os(Linux)
|
||||||
|
let myCAPath = URL(fileURLWithPath: #file).appendingPathComponent("../../Certs/Self-Signed/chain.pem").standardized
|
||||||
|
let myCertPath = URL(fileURLWithPath: #file).appendingPathComponent("../../Certs/Self-Signed/cert.pem").standardized
|
||||||
|
let myKeyPath = URL(fileURLWithPath: #file).appendingPathComponent("../../Certs/Self-Signed/key.pem").standardized
|
||||||
|
let config = TLSConfiguration(withCACertificateFilePath: myCAPath.path, usingCertificateFile: myCertPath.path, withKeyFile: myKeyPath.path, usingSelfSignedCerts: true)
|
||||||
|
#else
|
||||||
|
let myP12 = URL(fileURLWithPath: #file).appendingPathComponent("../../../Certs/Self-Signed/cert.pfx").standardized
|
||||||
|
let myPassword = "sw!ft!sC00l"
|
||||||
|
let config = TLSConfiguration(withChainFilePath: myP12.path, withPassword: myPassword, usingSelfSignedCerts: true)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
|
private func createCASignedTLSConfig() -> TLSConfiguration {
|
||||||
|
#if os(Linux)
|
||||||
|
|
||||||
|
let myCAPath = URL(fileURLWithPath: #file).appendingPathComponent("../../../Certs/letsEncryptCA/chain.pem").standardized
|
||||||
|
let myCertPath = URL(fileURLWithPath: #file).appendingPathComponent("../../../Certs/letsEncryptCA/cert.pem").standardized
|
||||||
|
let myKeyPath = URL(fileURLWithPath: #file).appendingPathComponent("../../../Certs/letsEncryptCA/key.pem").standardized
|
||||||
|
let config = TLSConfiguration(withCACertificateFilePath: myCAPath.path, usingCertificateFile: myCertPath.path, withKeyFile: myKeyPath.path, usingSelfSignedCerts: false)
|
||||||
|
// print("myCAPath is at: \(myCAPath.absoluteString) ")
|
||||||
|
// print("myCertPath is at: \(myCertPath.absoluteString) ")
|
||||||
|
// print("myKeyPath is at: \(myKeyPath.absoluteString) ")
|
||||||
|
|
||||||
|
#else
|
||||||
|
let myP12 = URL(fileURLWithPath: #file).appendingPathComponent("../../../Certs/letsEncryptCA/cert.pfx").standardized
|
||||||
|
let myPassword = "password"
|
||||||
|
let config = TLSConfiguration(withChainFilePath: myP12.path, withPassword: myPassword, usingSelfSignedCerts: false)
|
||||||
|
// print("myCertPath is at: \(myP12.absoluteString) ")
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
|
static var allTests = [
|
||||||
|
("testOkEndToEndTLSwithCA", testOkEndToEndTLSwithCA),
|
||||||
|
("testHelloEndToEndTLSwithCA", testHelloEndToEndTLSwithCA),
|
||||||
|
("testSimpleHelloEndToEndTLSwithCA", testSimpleHelloEndToEndTLSwithCA),
|
||||||
|
("testRequestEchoEndToEndTLSwithCA", testRequestEchoEndToEndTLSwithCA),
|
||||||
|
("testRequestKeepAliveEchoEndToEndTLSwithCA", testRequestKeepAliveEchoEndToEndTLSwithCA),
|
||||||
|
("testRequestLargeEchoEndToEndTLSwithCA", testRequestLargeEchoEndToEndTLSwithCA),
|
||||||
|
("testMultipleRequestWithoutKeepAliveEchoEndToEndTLSwithCA", testMultipleRequestWithoutKeepAliveEchoEndToEndTLSwithCA),
|
||||||
|
("testRequestLargePostHelloWorldTLSwithCA", testRequestLargePostHelloWorldTLSwithCA),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
#if os(OSX)
|
||||||
|
extension TLSServerTests: URLSessionDelegate {
|
||||||
|
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
||||||
|
completionHandler(URLSession.AuthChallengeDisposition.useCredential, URLCredential(trust: challenge.protectionSpace.serverTrust!) )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -11,7 +11,6 @@ import XCTest
|
|||||||
@testable import HTTP
|
@testable import HTTP
|
||||||
|
|
||||||
class VersionTests: XCTestCase {
|
class VersionTests: XCTestCase {
|
||||||
|
|
||||||
let version10 = HTTPVersion(major: 1, minor: 0)
|
let version10 = HTTPVersion(major: 1, minor: 0)
|
||||||
let version11 = HTTPVersion(major: 1, minor: 1)
|
let version11 = HTTPVersion(major: 1, minor: 1)
|
||||||
let version20 = HTTPVersion(major: 2, minor: 0)
|
let version20 = HTTPVersion(major: 2, minor: 0)
|
||||||
@@ -46,7 +45,6 @@ class VersionTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testLess() {
|
func testLess() {
|
||||||
|
|
||||||
XCTAssertLessThan(version10, version11)
|
XCTAssertLessThan(version10, version11)
|
||||||
XCTAssertLessThan(version10, version20)
|
XCTAssertLessThan(version10, version20)
|
||||||
XCTAssertLessThan(version11, version20)
|
XCTAssertLessThan(version11, version20)
|
||||||
@@ -64,9 +62,28 @@ class VersionTests: XCTestCase {
|
|||||||
XCTAssertFalse(version20 <= version11)
|
XCTAssertFalse(version20 <= version11)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testHashValue() {
|
||||||
|
XCTAssertEqual(version10.hashValue, HTTPVersion(major: 1, minor: 0).hashValue)
|
||||||
|
XCTAssertEqual(version11.hashValue, HTTPVersion(major: 1, minor: 1).hashValue)
|
||||||
|
XCTAssertEqual(version20.hashValue, HTTPVersion(major: 2, minor: 0).hashValue)
|
||||||
|
|
||||||
|
XCTAssertNotEqual(version10.hashValue, HTTPVersion(major: 1, minor: 1).hashValue)
|
||||||
|
XCTAssertNotEqual(version11.hashValue, HTTPVersion(major: 1, minor: 0).hashValue)
|
||||||
|
XCTAssertNotEqual(version20.hashValue, HTTPVersion(major: 1, minor: 0).hashValue)
|
||||||
|
XCTAssertNotEqual(version20.hashValue, HTTPVersion(major: 1, minor: 1).hashValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testDescription() {
|
||||||
|
XCTAssertEqual(version10.description, "HTTP/1.0")
|
||||||
|
XCTAssertEqual(version11.description, "HTTP/1.1")
|
||||||
|
XCTAssertEqual(version20.description, "HTTP/2.0")
|
||||||
|
}
|
||||||
|
|
||||||
static var allTests = [
|
static var allTests = [
|
||||||
("testEquals", testEquals),
|
("testEquals", testEquals),
|
||||||
("testGreater", testGreater),
|
("testGreater", testGreater),
|
||||||
("testLess", testLess),
|
("testLess", testLess),
|
||||||
|
("testHashValue", testHashValue),
|
||||||
|
("testDescription", testDescription)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,14 +8,13 @@
|
|||||||
|
|
||||||
import XCTest
|
import XCTest
|
||||||
@testable import HTTPTests
|
@testable import HTTPTests
|
||||||
@testable import BlueSocketHTTPTests
|
|
||||||
|
|
||||||
XCTMain([
|
XCTMain([
|
||||||
// HTTPTests
|
// HTTPTests
|
||||||
testCase(VersionTests.allTests),
|
testCase(VersionTests.allTests),
|
||||||
testCase(HeadersTests.allTests),
|
testCase(HeadersTests.allTests),
|
||||||
testCase(ResponseTests.allTests),
|
testCase(ResponseTests.allTests),
|
||||||
|
|
||||||
// BlueSocketHTTPTests
|
|
||||||
testCase(ServerTests.allTests),
|
testCase(ServerTests.allTests),
|
||||||
|
testCase(ServerTestsEndToEnd.allTests),
|
||||||
|
testCase(TLSServerTests.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>
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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>
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -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>
|
|
||||||
-597
@@ -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>
|
|
||||||
-236
@@ -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>
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -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>
|
|
||||||
-1951
File diff suppressed because it is too large
Load Diff
-345
@@ -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; }
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 274 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
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(), "\""];
|
|
||||||
});
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user