48 Commits
Author SHA1 Message Date
Artem Redkin 51dc885a30 add support for redirect limits (#113) 2019-10-23 19:29:25 +03:00
Johannes Weiss c1c3da3990 remove all deprecations (#116) 2019-10-22 17:52:11 -07:00
Artem Redkin 191c4ba506 add response decompression support (#86)
fixes #44
2019-10-22 17:45:12 -07:00
Artem Redkin 54b0b96b74 cancel should be done with outbound user event (#110)
cancel should be done with outbound user event
2019-09-23 16:43:15 +01:00
Johannes Weiss 513be15050 EventLoop preference overhaul (#102) 2019-09-21 21:33:15 +02:00
Artem Redkin 79cd718c35 preserve trailing slash in uri path (#107) 2019-09-20 15:32:49 +01:00
Trevör 6efe214716 Remove spaces in range operators (#104) 2019-09-17 13:28:05 +01:00
Johannes Weiss 2d7ae2bbae minor: improve code style (#103) 2019-09-15 11:04:11 +01:00
Johannes Weiss 1b31c5a4e3 give generic parameters nice names (#99) 2019-09-09 17:54:21 +01:00
vkill 47de4bb5ec Add authorization to proxy (#94) 2019-09-08 14:30:24 +01:00
Trevör 244aea673e Tolerate futures from arbitrary event loops (#96)
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.
2019-09-06 07:40:49 +01:00
Johannes Weiss 26afbc14bb make sure HTTPClient is shutdown (#98)
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.
2019-09-05 15:33:13 +01:00
Artem Redkin bbf7966992 nest timeout configuration type inside configuration (#93)
* nest timeout configuration type inside configuration

* move timeout to an extension
2019-08-31 09:49:56 +01:00
vkill 5156eb22b1 Fix forgot to set maxAge in Cookie init function (#91) 2019-08-24 11:21:05 +01:00
tomer doron b1eb92eb3d refactor proxy configuration (#90)
* 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
2019-08-24 08:58:51 +01:00
Ludovic Dewailly 8814439abe redirects ignore EventLoop preference - issue#88 (#89) 2019-08-21 11:26:19 +01:00
Artem Redkin 64851a1a0a add NIO event loop as an argument for execute (#79)
* 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
2019-08-20 17:50:10 +01:00
Artem Redkin e9d0dd2cc9 rename didReceivePart to didReceiveBodyPart (#84) 2019-08-17 13:32:51 +01:00
vkill e0eeb0481c Ignore uncleanShutdown error when state is .head or .body (#77)
* 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
2019-08-15 11:55:33 +01:00
Trevör 690e8ee797 Add @discardableResult to HTTPHandler setChannel method (#81)
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.
2019-08-14 11:06:32 +01:00
vkill 912005b4f1 Add init to HTTPClient.Response (#75) 2019-08-12 15:15:00 +01:00
tomer doron e64448e1ef improve request validation (#67)
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
2019-07-30 09:55:38 -07:00
tomer doron bab22d0ebd test formatting issues as part of sanity check (#73)
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
2019-07-30 10:00:10 +01:00
Artem Redkin 53d5bce8ee call didSendRequest after write future is fullfilled (#65) 2019-07-24 12:53:35 +01:00
Artem RedkinandJoe Smith 0c617a4d7f document public API (#62)
Co-Authored-By: Joe Smith <yasumoto7@gmail.com>
2019-07-17 10:56:54 +01:00
Artem Redkin a42fe83781 remove unused degate and make other one public+rename (#61) 2019-07-04 07:53:58 +01:00
Artem Redkin 9b1e9d3640 add deadlines (#57) 2019-07-03 14:40:26 +03:00
Tobias daf66bde06 Make sure that event loop of task is the same as event loop of channel (#55) 2019-07-03 12:39:42 +01:00
Artem Redkin 27fe9265b2 rename to async-http-client (#58) 2019-07-02 14:00:34 +03:00
Andrew Lees 022bb50d4c Add support for percent encoded requests (#52) 2019-06-25 13:44:17 +03:00
Artem Redkin 34e3403cca Task refactoring (#47)
* refactor Task to encapsulate promise
2019-06-24 16:30:03 +03:00
George Barnett d32eea00dd Pass timeout from get/post/patch/put/delete to execute (#48) 2019-06-22 12:58:58 +03:00
Artem Redkin b019e0887c Upload streaming (#37)
* 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
2019-06-17 20:21:10 +03:00
tomer doron 100b04b02d move elg provider as a nested class of the client (#40)
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
2019-06-02 10:40:00 -07:00
Joe Smith 93682abeb5 HTTPCookie is a subtype of HTTPClient (#36)
* HTTPCookie is a subtype of HTTPClient to not collide with Foundations top-level type
2019-05-22 14:31:00 +01:00
Artem Redkin 317f4fa665 close connections after request is processed (#34)
* close connections after request is processed
2019-05-15 10:12:19 +01:00
Trevör 44ddc8bae0 Transfer scheme and host to new request when redirected (#20)
* 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
2019-04-27 13:34:58 +01:00
Tanner b9c5535baf publicize client's elg (#24) 2019-04-26 19:26:07 -04:00
Trevör 69564cc57b Rename references of HTTPClientConfiguration to HTTPClient.Configuration (#19) 2019-04-25 18:19:17 -04:00
Ian Partridge eda51acd9d feat: Add HTTPClient.patch() for sending PATCH requests (#15)
`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`.
2019-04-18 21:55:12 +01:00
Tanner 15ee7ee73e add proxy support (#1) 2019-04-16 10:07:53 +01:00
tomer doron 0cf27fc53c some refactoring (#10)
* 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
2019-04-15 17:37:53 +01:00
Ian Partridge a6c9f861c3 Pass HTTPTask to HTTPResponseDelegate methods (#13) 2019-04-12 11:36:09 +01:00
Ian Partridge db60d3d32b fix: length calculation of .string HTTPBody (#11)
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.
2019-04-11 23:48:14 +01:00
tomer doron 4acd312a5a fix formatting (#12)
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
2019-04-11 15:46:30 -07:00
tomer doron 9b01f9d9c1 add collateral (#7)
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
2019-04-10 16:07:35 -07:00
Artem Redkin 58ea0c5ba8 Motivation:
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
2019-04-10 20:33:44 +01:00
Artem Redkin da770caf2e initial commit 2019-04-01 18:51:15 +01:00