libcurl-backed URLSession cannot communicate with ChromeDriver's HTTP server
Opened this issue · 0 comments
kateinoigakukun commented
corelibs-foundation's URLSession backed by libcurl fails to communicate with ChromeDriver's HTTP server.
Reproducer
$ curl -LO https://storage.googleapis.com/chrome-for-testing-public/125.0.6422.78/linux64/chromedriver-linux64.zip
$ unzip chromedriver-linux64.zip
$ ./chromedriver-linux64/chromedriver-p 9515
$ swiftc main.swift && ./main
Error: Error Domain=NSURLErrorDomain Code=-1 "(null)"
Failed writing header
// File: main.swift
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
do {
var request = URLRequest(url: URL(string: "http://127.0.0.1:9515/session")!)
request.httpMethod = "POST"
let _: (Data, URLResponse) = try await withCheckedThrowingContinuation { continuation in
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
guard let data = data, let response = response else {
let error = error ?? URLError(.badServerResponse)
return continuation.resume(throwing: error)
}
continuation.resume(returning: (data, response))
}
task.resume()
}
} catch {
print("Error: \(error)")
print(error.localizedDescription)
exit(1)
}
Note that the above script works on macOS and corresponding curl CLI command (curl -X POST http://127.0.0.1:9515/session
) returns a response well.
Platform
Ubuntu 22.04 (This should be reproducible on all platforms with corelisb-foundation in theory)
Toolchain version
DEVELOPMENT-SNAPSHOT-2024-05-15-a
Swift version 6.0-dev (LLVM cef183591317ec7, Swift 66e311074bff491)
Target: x86_64-unknown-linux-gnu