Skip to content

Commit

Permalink
Add % encoding in ClientRequest.init, remove % encoding in HTTPServer…
Browse files Browse the repository at this point in the history
…Request.init
  • Loading branch information
Pushkar N Kulkarni committed Feb 20, 2019
1 parent a54fffe commit 8e4088c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/KituraNet/ClientRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public class ClientRequest {
if thePath.first != "/" {
thePath = "/" + thePath
}
path = thePath
path = thePath.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlPathAllowed) ?? thePath
self.path = path
case .username(let userName):
self.userName = userName
Expand Down
2 changes: 1 addition & 1 deletion Sources/KituraNet/HTTP/HTTPServerRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public class HTTPServerRequest: ServerRequest {
self.method = requestHead.method.string()
self.httpVersionMajor = requestHead.version.major
self.httpVersionMinor = requestHead.version.minor
self._urlString = requestHead.uri
self._urlString = requestHead.uri.removingPercentEncoding ?? requestHead.uri
self.enableSSL = enableSSL
}

Expand Down
7 changes: 7 additions & 0 deletions Tests/KituraNetTests/ClientRequestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ class ClientRequestTests: KituraNetTest {
let options = ClientRequest.parse("https://username:password@66o.tech:8080/path?key=value")
let testRequest = ClientRequest(options: options, callback: testCallback)
XCTAssertEqual(testRequest.url, "https://username:password@66o.tech:8080/path?key=value")

let options1: [ClientRequest.Options] = [ .schema("https"),
.hostname("66o.tech"),
.path("/view/matching?key=\"viewTest\"")
]
let testRequest1 = ClientRequest(options: options1, callback: testCallback)
XCTAssertEqual(testRequest1.url, "https://66o.tech/view/matching?key=%22viewTest%22")
}

func testClientRequestBasicAuthentcation() {
Expand Down

0 comments on commit 8e4088c

Please sign in to comment.