You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While debugging an issue when using Alamofire 5 on Linux I discovered the root cause to be a difference in behavior between Darwin and Linux Foundation when retrieving a url from an existing URLRequest (or NSURLRequest) for relative URL's. Consider the following code:
import Foundation
let baseUrl = URL(string: "http://httpbin.org")
let url = URL(string: "/get", relativeTo: baseUrl)!
Notice the difference in output. It looks like the .url property on Darwin is assigned a resolved absolute URL when NSURLRequest and URLRequest objects are constructed, however, a reassignment to .url property preserves the relative URL.
The text was updated successfully, but these errors were encountered:
ianpartridge (JIRA User), @parkera, @phausler, @spevans, @millenomi, @jshier What do you think is the best approach to fix this? I am inclined to fix this in the Foundation to make behavior match between OSX and Linux. Does the swift-4.2 branch still accept fixes? Thanks!
For Foundation, if there is a difference between macOS and Linux and no obvious bug on the macOS side, the Linux behaviour is altered to match macOS as it is assumed to be the default correct way of working.
The swift-4.2 branch is still open for various bug fixes but any fix would go into the master branch first.
Additional Detail from JIRA
md5: 08f9a1361d058da4c1f91e5e024291c0
Issue Description:
While debugging an issue when using Alamofire 5 on Linux I discovered the root cause to be a difference in behavior between Darwin and Linux Foundation when retrieving a url from an existing URLRequest (or NSURLRequest) for relative URL's. Consider the following code:
import Foundation
let baseUrl = URL(string: "http://httpbin.org")
let url = URL(string: "/get", relativeTo: baseUrl)!
print("url = (url)")
print("base = (url.baseURL!)")
print("relativeString = (url.relativeString)")
var req = URLRequest(url: url)
print("req.url = (req.url!)")
req.url = url
print("req.url = (req.url!)")
var nsreq = NSURLRequest(url: url)
print("nsreq.url = (nsreq.url!)")
Darwin output:
url = /get – http://httpbin.org
base = http://httpbin.org
relativeString = /get
req.url = http://httpbin.org/get
// reassignment happens here
req.url = /get – http://httpbin.org
nsreq.url = http://httpbin.org/get
Ubuntu output:
url = /get – http://httpbin.org
base = http://httpbin.org
relativeString = /get
req.url = /get – http://httpbin.org
// reassignment happens here
req.url = /get – http://httpbin.org
nsreq.url = /get – http://httpbin.org
Notice the difference in output. It looks like the .url property on Darwin is assigned a resolved absolute URL when NSURLRequest and URLRequest objects are constructed, however, a reassignment to .url property preserves the relative URL.
The text was updated successfully, but these errors were encountered: