This commit fixes#95 by always hopping event loop futures received from
the delegate to the right event loop. This could be a source of bugs if
the library users forgot to hop(to:) futures from their delegates
implementations.
Motivation:
Right now, HTTPClient only asserts that it's shut down if it was started with its own EventLoopGroup.
That however is weird because it's lifecycle model depends on the parameters you pass to `init`.
Modifications:
Always validate the lifecycle (in debug mode).
Result:
API makes more sense.
* refactor proxy configuration
motivation: make proxy configuration follow same convention as other configuration
changes:
* nest Proxy under HTTPClient.Configuration instad of top level HTTPClient
* make host and port public and mutable, following convention of other configuration objects in this library
* add some API docs
* fixup
* add NIO event loop as an argument for execute
* review fix: add to np-delegate method as well
* Resolve confict
* add missing linux test
* fix formatting
* missing self
* review fix: add event loop preference argument instead of eventloop
* formatting
* review fix: spelling
* fix compilation error
* review fixes: make preference argument not explicit and add precondition that EL must be part of ELG
* Ignore uncleanShutdown error when state is head or body
* Add ignoreNIOSSLUncleanShutdownError to Configuration
* Revert old HTTPClient.init founctions
* Run generate_linux_tests.rb
* Rename ignoreNIOSSLUncleanShutdownError to ignoreUncleanSSLShutdown
* Make tests compatible with swift 5.0
The only place where this method is currently called uses its return
value, but that's specific to the context where it's used (inside of
chained calls to map/flatMap). Future uses might not always need to use
the return value since it is the same as what's passed as the method
argument.
motivation: safer handling of request validation and mutation
changes:
* drop request version
* made request method and url immutable
* made request scheme and host internal
* fix scheme logic to be non-case sensitive
* adjusted redirect handler implementation to stricter request immutabllity
* adjust and add tests
motivaiton: unified format
changes:
* fix outstanding formatting issues
* add a call to swiftformat as part of sanity script
* fix sanity script language check debugging statements
* Provide a way to stream Request.body
Motivation:
Users may want to optimize memory usage when executing request with big
bodies, same as streaming download
Modifications:
Added ChunkProvider typealias in HTTPHandler.swift
Added new Body enum case - stream in HTTPHandler.swift
Extracted body processing in HTTPHandler.swift to a separate method
Added .stream enum processing in HTTPHandler.swift
Added upload streaming test to SwiftNIOHTTPTests.swift
Result:
HTTPClient library now provides methods to stream Request body
motivation: elg provider is likely to be a common pattern in client libraries (eg db drivers), lets prevent type clashes
changes: make EventLoopGroupProvider a nested class of HTTPClient
* Transfer scheme and host to new request when redirected
This solves a bug that could cause infinite redirections (eg: requesting example.com, being redirected to www.example.com, but requesting again example.com as host hadn't been correctly specified)
* Check that redirect correctly modifies Host to what's specified by the server response
* Move test to new test case, use Decodable inline struct instead of JSONSerialization
* Run swiftformat tool
* Use NIOFoundationCompat helper functions
* Stop using httpbin.org and use the local HttpBin server for the testHttpHostRedirect test
* Reformat files
* Check that redirectURL contains a host and scheme
* Run swiftformat
* Replace assertionFailure with preconditionFailure
`PATCH` is a commonly supported verb in RESTful APIs. Although it is
already possible to send a PATCH request via the `HTTPClient.execute()`
API this commit adds an explicit `patch()` API for consistency.
This gives us explicit APIs for `GET`, `POST`, `PUT`, `PATCH` and
`DELETE`.
* some refactoring
motivation: better code structure
changes:
* abstract errors as enum instead of nested structs
* make configurationa nested class
* errors as static let
* * move request, response, task to be nested under HTTPClient
* rename HTTPResponseDelegate -> HTTPClientResponseDelegate
* adjust tests
* Update SwiftNIOHTTP.swift
Currently, if an `HTTPBody` is set to .string, the length is calculated as
string.count. In Swift, this is the number of extended grapheme clusters, not
the UTF8 byte count. Instead, we should use the count of the UTF8View, as the
bytes will be transmitted in this encoding.
motivation: use consistent formatting
changes:
* run `swiftformat --self insert --patternlet inline --stripunusedargs unnamed-only --comments ignore` which is the standard formatting we use
* update generate_linux_tests to follow same formatting rules
motivation: min requirements by sswg
changes:
* add code of conduct, contributors
* add docker setup for ci
* add linux docs generation and sanity check scripts
* add api documentation generation script
Naming in different Swift projects should be consistent, in order to
achieve this I propose (as recommended by @tomerd) to rename
SwiftNIOHTTP to NIOHTTPClient
Modifications:
Updated naming in Package.swift
Renamed directories Sources/SwiftNIOHTTP and Tests/SwiftNIOHTTPTests to
Sources/NIOHTTPClient and Tests/NIOHTTPClientTests
Updated imports in tests
Result:
Package is now called NIOHTTPClient