Kitura / SwiftyRequest

SwiftyRequest is an HTTP networking library built for Swift.
Apache License 2.0
110 stars 19 forks source link

Fix overwriting of queryItems with nil #51

Closed djones6 closed 5 years ago

djones6 commented 5 years ago

Resolves #42

RestRequest provides two ways to configure the query parameters for the request: one is by setting the queryItems field, the other is by passing them to one of the func responseXXX(..., queryItems:) functions.

If the queryItems param is not provided, it defaults to nil. However, that then unconditionally overwrites the values on the RestRequest. This seems counter-intuitive, and means the only way to use the currently configured queryItems would be to pass it as a parameter, ie. request.responseObject(..., queryItems: request.queryItems).

This PR makes the overwriting conditional on the queryItems param being non-nil.

Following this change, it is no longer possible to (explicitly or implicitly) pass queryItems: nil to clear the current query parameters. Instead, the user should set request.queryItems = nil before calling a response function.