101 Commits
Author SHA1 Message Date
Aaron LiberatoreandChris Bailey d81bed005d Adds Travis Support (#53)
* adds travis file

* adds travis file

* Exclude gh-pages branch from travis
2017-09-24 13:28:05 +01:00
Aaron LiberatoreandChris Bailey 00adc53d0f Closes requests with Connection: close header (#52)
* Closes requests with Connection: close header

* Fixes whitespace and merge mistake
2017-09-24 13:27:14 +01:00
Carl BrownandChris Bailey 280caad31d Honor &stopProcessingBody flag, with tests (#51)
Issue #48
2017-09-22 08:50:20 +01:00
Carl BrownandGitHub 327e890e55 Merge pull request #41 from djones6/keepalive
Correct function of Keep-Alive header
2017-09-19 10:09:51 -05:00
David Jones a8205d2b7a Remove Keep-Alive header 2017-09-19 14:21:40 +01:00
David Jones 62aba99de0 Revise naming and type for requests remaining var 2017-09-19 14:17:30 +01:00
David Jones ee4b4d9620 Correct function of keepalive header 2017-09-19 14:17:13 +01:00
Chris BaileyandGitHub fee5702695 Fix port configuration being ignored (#42) 2017-09-11 13:59:04 +01:00
Chris BaileyandGitHub 055a757e15 Update README.md and Jazzy annotations (#43) 2017-09-10 16:21:20 +01:00
Carl BrownandChris Bailey 6b5b27edf0 Remove BlueSocket dependency (#39) 2017-09-08 11:46:08 +01:00
Chris BaileyandGitHub d53f9432ce Perf: read connectionCount only when needed (#23) 2017-08-29 12:48:12 +01:00
Carl BrownandChris Bailey 8d278305c1 Remove dangling reference left over from rename in PR #26 (#38)
This enables the tests to run in Linux again
2017-08-29 08:52:41 +01:00
Chris BaileyandGitHub 75f022c06d Remove need for utils.* in CHTTPParser (#35) 2017-08-27 10:14:35 +01:00
Ian PartridgeandChris Bailey 6c0317d239 Add .swiftlint.yml and clean up project (#33) 2017-08-24 18:15:50 +01:00
Ian PartridgeandChris Bailey 0a09bcac28 Remove CHTTPParser dependency, add target (#32) 2017-08-23 18:52:07 +01:00
Ian PartridgeandChris Bailey ab8f280798 Remove API docs (#29)
* Update API docs

* Remove docs directory and update .gitignore
2017-08-23 14:17:00 +01:00
Ian PartridgeandChris Bailey 92f3ee4dc0 Add HTTPServer API (#26) 2017-08-23 10:44:04 +01:00
Chris BaileyandGitHub 8f1f900474 Add initial set of Jazzy docs (#24) 2017-08-13 08:03:55 +01:00
Aleksey MashanovandChris Bailey 6e6ffe2124 Simplification of HTTPResponse/HTTPResponseWriter (#19)
* Simplification of HTTPResponse/HTTPResponseWriter

* `HTTPResponse` is redundent. Its `status` and `headers` properties
  are moved to parameters of `writeHeader` method of `HTTPResponseWriter`
  instance. `transferEncoding` handling is moved to `HTTPHeaders` - it
  is not as simple as an enum and depends on used HTTP protocol version
  and capabilites set by a client in its request headers.
  `httpVersion` should not be configured by an outer scope - a server should
  use the HTTP version which was requested by a client.

* `writeResponse` and `writeContinue` are replaced by `writeHeader`.

* `writeTrailer` accepts trailers as `HTTPHeaders` struct.

* All `write*` methods accept a completion handler.

* `writeBody` accepts `UnsafeHTTPResponseBody` instead of just `Data`
  and `Dispatch`. It should be used only in the scope of a call and a
  copy should be made or value should be checked for `HTTPResponseBody`
  conformance before storing it anythere. This approch allows to reduce
  memory copying.

* `Result<POSIXError, Void>` enum is replaced with `Result`. In the
  first case `POSIXError` and `Void` are generic parameters names, not
  types. I think this behaviour was unintended.

* Always respond with HTTP/1.1 for any HTTP/1.x requests

* Get back HTTPResponse for possible use in the client
2017-07-17 14:06:47 +01:00
Carl BrownandChris Bailey 0da680a181 Fix for exclusive access issue in Swift 4 (#21) 2017-07-15 11:15:44 +01:00
Carl BrownandGitHub 378286eea3 Merge pull request #18 from seabaylea/discardBody
.discardBody should call done()
2017-06-30 12:03:44 -05:00
seabaylea 48d155f3ed discardBody() should call done() 2017-06-30 17:34:54 +01:00
Chris BaileyandGitHub 43702318d4 Convert HTTPMethod to a struct (#17)
* Convert HTTPMethod to a struct

* Compare on rawValue rather than description

* Remove RawRepresentable and add ExpressibleByStringLiteral conformance
2017-06-30 17:11:20 +01:00
Chris BaileyandGitHub 8ad751d04d Add Comparable conformance to HTTPVersion (#15)
* Add Comparable conformance to HTTPVersion

* Remove superfluous comparable operators and clean up hash collisions

* Remove unnecessary != implementation
2017-06-30 17:11:00 +01:00
Younes MantonandChris Bailey af9c374f5c Grab the lock around count and closeAll operations (#16) 2017-06-28 20:37:26 +01:00
aleksey-mashanovandChris Bailey 7e366e4687 Make HTTPHeaders more user-friendly (#14)
* Make HTTPHeaders more user-friendly

* Header name is a struct conforming to `ExpressibleByStringLiteral`.
  Standard header names are available through static constants.
  This allows to save some CPU on lowercasing and hash value
  calculation.

* Original headers are stored until first modification. Iterator
  of `HTTPHeaders` iterates over original headers while they are actual,
  in other case it iterates over underlying mutable dictionary.

* Default subscript returns values of all headers with the same
  name concatenated with comma [RFC7230, section 3.2.2], except
  for "Set-Cookie" for which only first value is returned.

* As-is values of all headers with same name can be accessed
  through subscript with label `valuesFor`.

* append() method is modified to accept dictionary literal.
  replace() method is added.

* Split HTTPHeaders implementation to separate extensions
2017-06-28 12:54:41 +01:00
aleksey-mashanovandChris Bailey 002d9ce17b Convert HTTPResponseStatus to a struct (#12)
* Convert HTTPResponseStatus to a struct

* `HTTPResponseStatus` is a struct now. It is better then an enum
  in this case because it could be possible to provide an alternative
  reason phrase as allowed by RFC7231:
  "The reason phrases listed here are only recommendations -- they
  can be replaced by local equivalents without affecting the protocol."

* `HTTPResponseStatus` struct is smaller then enum. Struct's size(stride)
  are 32(32) whereas enum's are 33(40).

* Removed conformance to protocol `RawRepresentable` because custom
  reason phrases conflict with the message of `RawRepresentable`:
  "With a RawRepresentable type, you can switch back and forth between a
  custom type and an associated RawValue type without losing the value
  of the original RawRepresentable type."

* Added conformance to `CustomStringConvertble` to provide an easy
  conversion to HTTP status line.

* Added conformance to `ExpressibleByIntegerLiteral` to provide an
  easy way to pass numeric value instead of `.humanReadable`.
  For many server-side developers 200, 404 and 500 have much more
  meaning then `.ok`, `.notFound` and `.internalServerError`.

* Added `class` property in conformance with RFC7231 recommendation:
  "HTTP clients are not required to understand the meaning of all
  registered status codes, though such understanding is obviously
  desirable.  However, a client MUST understand the class of any
  status code, as indicated by the first digit, and treat an
  unrecognized status code as being equivalent to the x00 status
  code of that class..."

* Update API documentation for HTTPResponseStatus

* Modify type of HTTP status-code: UInt16 -> Int

`Int` better match Swift API guidelines then `UInt16` and
requires the same memory in struct because of alignment.

* Swiftify HTTPResponseStatus initializers
2017-06-22 13:04:46 +01:00
TannerandChris Bailey 5a16db4ccb move response write convenience methods to extension (#10) 2017-06-20 16:56:04 +01:00
Chris BaileyandGitHub f75476055d Merge pull request #9 from tanner0101/just-modules
just modules
2017-06-19 16:53:35 +01:00
TannerandGitHub 3a21866782 rename Request to HTTPRequest 2017-06-16 11:51:32 +01:00
tanner0101 9691a6a526 spacing fixes 2017-06-14 18:59:07 +01:00
tanner0101 02ef28a81e resolve merge conflicts with HTTPVersion updates 2017-06-14 18:56:20 +01:00
tanner0101 205a2652fc Merge branch 'develop' into just-modules 2017-06-14 18:55:29 +01:00
TannerandGitHub 9c12770490 Merge pull request #1 from swift-server/develop
bring in latest updates
2017-06-14 18:55:00 +01:00
Chris BaileyandGitHub fbd4208900 Merge pull request #6 from seabaylea/httpversion
Convert HTTPVersion to a struct
2017-06-14 18:51:18 +01:00
tanner0101 990a38227a clean up modules 2017-06-14 18:42:36 +01:00
tanner0101 6c6c1b1ad4 remove resolved 2017-06-14 13:45:14 +01:00
tanner0101 80111f16b1 modules / namespace 2017-06-14 13:44:45 +01:00
seabaylea 58eb012735 Move HTTPVersion to its own file and add
Hashable/CustomStringConvertible conformance
2017-06-14 10:19:31 +01:00
seabaylea db44cf0d1a Convert HTTPVersion to a struct 2017-06-13 15:31:15 +01:00
Chris BaileyandGitHub 7c04fa59d3 Merge pull request #5 from shmuelk/develop
Make StreamingParser.keepAliveUntil accessable outside the SwiftServerHttp module
2017-06-12 09:51:40 +01:00
Chris BaileyandGitHub f66aa823e0 Merge pull request #3 from helje5/proposals/enums-need-to-be-open
HTTPMethod/HTTPResponseStatus enums need to be open
2017-06-12 09:43:43 +01:00
Shmuel Kallner 8feb666b6f Make keepAliveUntil accessable outside this module 2017-06-07 14:54:23 +03:00
Helge Hess 885d1f1ec4 Fix reasonPhrase, update API.md 2017-06-01 13:33:41 +02:00
Helge Hess 9fdf40ff74 Add .other to HTTPResponseStatus
HTTP is a living protocol, status values are
occasionally added.
I would prefer that we wouldn't use a closed
construct like an enum for an extensible type,
but at least we need to have a 'other' case
to be future-proof.
2017-06-01 13:20:51 +02:00
Helge Hess dd9e50172c Add .other to HTTPMethod
HTTP is a living protocol, methods are added
all the time.
I would prefer that we wouldn't use a closed
construct like an enum for an extensible type,
but at least we need to have a 'other' case
to be future-proof.
2017-06-01 13:19:52 +02:00
Chris BaileyandGitHub 8b610c9655 Merge pull request #2 from swift-server/relocateSimpleResponseCreator
relocate SimpleResponseCreator
2017-05-31 16:21:29 +01:00
Carl Brown cbb6387f00 relocate SimpleResponseCreator 2017-05-31 10:03:20 -05:00
Carl BrownandGitHub 12cec86860 Merge pull request #1 from seabaylea/licence
Update LICENCE and copyrights, add API.md
2017-05-31 09:53:39 -05:00
seabaylea addb1029cf Update LICENCE and copyrights, add API.md 2017-05-31 15:47:49 +01:00