async-http-client
async-http-client copied to clipboard
Fix leading slash issue in relative URL requests
Motivation:
- When the leading slash is omitted in the
stringargument of a relativeURLinstance constructed frominit(string:relativeTo), requests made with thisURLinstance fail. This is because the underlying HTTP parser fails when there is no leading slash in the URI.
Modifications:
- The URI of a
URLinstance is obtained from a computed propertyuriinHTTPHandler.swift, which in turn calls thepercentEncodedPathcomputed property.- The
percentEncodedPathproperty usesURLComponentsto extract out the path. - The
resolvingAgainstBaseURLargument to theURLComponentsconstructor was modified fromfalsetotrue
- The
Result:
- Regardless of whether a user provides or omits a leading slash in the path of a relative
URL, theuriproperty will always contain a leading slash.