Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libcurl-backed URLSession cannot communicate with ChromeDriver's HTTP server #4965

Open
kateinoigakukun opened this issue May 26, 2024 · 0 comments

Comments

@kateinoigakukun
Copy link
Member

kateinoigakukun commented May 26, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant