# \#urlsession

**URL:** https://forums.swift.org/tag/urlsession/176.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [Designing an HTTP Client API for Swift](https://forums.swift.org/t/designing-an-http-client-api-for-swift/85254)

<div class="topic-metadata">

**Author:** [@Guoye](https://forums.swift.org/u/Guoye)\
**Replies:** 17\
**Last updated:** [March 31, 2026, 8:59pm UTC](https://forums.swift.org/t/designing-an-http-client-api-for-swift/85254 "2026-03-31T20:59:36Z")

</div>

HTTP is the internet’s foundational application-layer protocol. In fact, you probably just used it to view this post. Today we want to kick off the effort to design a new unified HTTP Client API to improve the experience…

---

## [Windows-specific timeout issue with URLSession in Swift (Error Code -1001)](https://forums.swift.org/t/windows-specific-timeout-issue-with-urlsession-in-swift-error-code-1001/81259)

<div class="topic-metadata">

**Author:** [@TimBudarick](https://forums.swift.org/u/TimBudarick)\
**Replies:** 4\
**Last updated:** [August 11, 2025, 10:14am UTC](https://forums.swift.org/t/windows-specific-timeout-issue-with-urlsession-in-swift-error-code-1001/81259 "2025-08-11T10:14:55Z")

</div>

Hello everyone, :waving\_hand:t3::cowboy\_hat\_face: I've been struggling with a persistent issue for several weeks and would greatly appreciate any insights or suggestions from the community. :red\_exclamation\_mark:Proble…

---

## [Is there anyone successfully using URLSession tasks on Windows VM?](https://forums.swift.org/t/is-there-anyone-successfully-using-urlsession-tasks-on-windows-vm/73697)

<div class="topic-metadata">

**Author:** [@ShikiSuen](https://forums.swift.org/u/ShikiSuen)\
**Replies:** 8\
**Last updated:** [August 11, 2025, 4:07am UTC](https://forums.swift.org/t/is-there-anyone-successfully-using-urlsession-tasks-on-windows-vm/73697 "2025-08-11T04:07:46Z")

</div>

I have written the following two SPM using URLSession to fetch remote data: This is how I use the URLSession API: They work fine on Linux and Apple systems. However, they both fail on Windows. As soon as the …

---

## [\[Pitch\] Early Data Support in URLSession on Darwin](https://forums.swift.org/t/pitch-early-data-support-in-urlsession-on-darwin/80071)

<div class="topic-metadata">

**Author:** [@Guoye](https://forums.swift.org/u/Guoye)\
**Replies:** 2\
**Last updated:** [May 23, 2025, 4:30am UTC](https://forums.swift.org/t/pitch-early-data-support-in-urlsession-on-darwin/80071 "2025-05-23T04:30:27Z")

</div>

Hi all, I'd like to share a proposal Introducing a flag to opt in to HTTP/3 early data in the new HTTP loader on Darwin. The API is not currently available non-Darwin platforms. Please check out the details below. Earl…

---

## [\[Pitch\] New HTTP loader for URLSession on Darwin](https://forums.swift.org/t/pitch-new-http-loader-for-urlsession-on-darwin/77440)

<div class="topic-metadata">

**Author:** [@Guoye](https://forums.swift.org/u/Guoye)\
**Replies:** 5\
**Last updated:** [February 4, 2025, 7:37pm UTC](https://forums.swift.org/t/pitch-new-http-loader-for-urlsession-on-darwin/77440 "2025-02-04T19:37:11Z")

</div>

Hi all, I'd like to share a proposal about the new HTTP loader for URLSession on Darwin. The API is not currently available non-Darwin platforms. Please check out the details below. New HTTP loader for URLSession Prop…

---

## [Reuse HTTP Client code in iOS app and Linux server?](https://forums.swift.org/t/reuse-http-client-code-in-ios-app-and-linux-server/76998)

<div class="topic-metadata">

**Author:** [@rkobylinski](https://forums.swift.org/u/rkobylinski)\
**Replies:** 6\
**Last updated:** [January 5, 2025, 1:11pm UTC](https://forums.swift.org/t/reuse-http-client-code-in-ios-app-and-linux-server/76998 "2025-01-05T13:11:38Z")

</div>

Hi! I‘d like to access a third party API from both an iOS app, as well as a Vapor server app, which l am deploying on Heroku. I wonder what the best approach would be to reuse the client code. Vapor offers a Client AP…

---

## [URLSession and custom \`WWW-Authenticate\`](https://forums.swift.org/t/urlsession-and-custom-www-authenticate/73966)

<div class="topic-metadata">

**Author:** [@nmgswift](https://forums.swift.org/u/nmgswift)\
**Replies:** 2\
**Last updated:** [August 15, 2024, 2:39pm UTC](https://forums.swift.org/t/urlsession-and-custom-www-authenticate/73966 "2024-08-15T14:39:58Z")

</div>

Hello call! I am attempting to use the URLSession API to call an endpoint with a custom WWW-Authenticate scheme. For some reason, instead of allowing me to respond to this in the challenge handler function of my delegat…

---

## [Incorrect URL Formation for API Request with Multi-Word Artist Names](https://forums.swift.org/t/incorrect-url-formation-for-api-request-with-multi-word-artist-names/72497)

<div class="topic-metadata">

**Author:** [@lexypaul13](https://forums.swift.org/u/lexypaul13)\
**Replies:** 2\
**Last updated:** [June 22, 2024, 10:42pm UTC](https://forums.swift.org/t/incorrect-url-formation-for-api-request-with-multi-word-artist-names/72497 "2024-06-22T22:42:54Z")

</div>

I am working on an iOS application in Swift that fetches song lyrics using a REST API. However, I am facing an issue with constructing the correct URL when the artist or title names contain multiple words. Problem: Whe…

---

## [URLSession Stream NDJSON Help?](https://forums.swift.org/t/urlsession-stream-ndjson-help/72321)

<div class="topic-metadata">

**Author:** [@JCKL](https://forums.swift.org/u/JCKL)\
**Replies:** 1\
**Last updated:** [June 9, 2024, 5:24am UTC](https://forums.swift.org/t/urlsession-stream-ndjson-help/72321 "2024-06-09T05:24:53Z")

</div>

I wish I could use web sockets, but this use case can only use HTTP. I'm trying to stream data from a swift client to a server that reads NDJSON. I can upload the data just fine as single requests (it opens a new conne…

---

## [Does Concurrency Work in Docker?](https://forums.swift.org/t/does-concurrency-work-in-docker/72235)

<div class="topic-metadata">

**Author:** [@sobabear](https://forums.swift.org/u/sobabear)\
**Replies:** 5\
**Last updated:** [June 6, 2024, 5:24am UTC](https://forums.swift.org/t/does-concurrency-work-in-docker/72235 "2024-06-06T05:24:51Z")

</div>

my docker file is # Use the official Swift image from the Docker Hub FROM swift:5.10 # Set a working directory inside the container WORKDIR /app # Copy the Package.swift and Sources directory into the container at /ap…

---

## [URLSession download of a large file took ages](https://forums.swift.org/t/urlsession-download-of-a-large-file-took-ages/71061)

<div class="topic-metadata">

**Author:** [@KrisSimon](https://forums.swift.org/u/KrisSimon)\
**Replies:** 9\
**Last updated:** [April 4, 2024, 3:17am UTC](https://forums.swift.org/t/urlsession-download-of-a-large-file-took-ages/71061 "2024-04-04T03:17:52Z")

</div>

Hi, can someone tell why downloading the same file in Safari is fast (8sec), but from within my script it takes ages (40min)? private func download() async -\> Data? { do { let configuration = UR…

---

## [Swift concurrency: return cache and then load remote](https://forums.swift.org/t/swift-concurrency-return-cache-and-then-load-remote/71068)

<div class="topic-metadata">

**Author:** [@mhergon](https://forums.swift.org/u/mhergon)\
**Replies:** 3\
**Last updated:** [April 3, 2024, 10:02pm UTC](https://forums.swift.org/t/swift-concurrency-return-cache-and-then-load-remote/71068 "2024-04-03T22:02:26Z")

</div>

Hi, Is there any way to return a value instantly and then reload the remote resources in an async/await call? I want to serve cached response, reload remote data and return on asynchronous call finish. Is it possible? …

---

## [Need help to debug hanging URLSessionDataTask on Linux with FoundationNetworking](https://forums.swift.org/t/need-help-to-debug-hanging-urlsessiondatatask-on-linux-with-foundationnetworking/70359)

<div class="topic-metadata">

**Author:** [@KrisSimon](https://forums.swift.org/u/KrisSimon)\
**Replies:** 6\
**Last updated:** [February 29, 2024, 10:51pm UTC](https://forums.swift.org/t/need-help-to-debug-hanging-urlsessiondatatask-on-linux-with-foundationnetworking/70359 "2024-02-29T22:51:33Z")

</div>

Hello, Before I describe my problem in detail, I would like to summarize the situation I am in, because I think this is important to understand my problem. I hope someone can give me give me an idea to help me troublesh…

---

## [URLSession "data(for request: URLRequest, delegate:) async throws -\> (Data, URLResponse)" function migration?](https://forums.swift.org/t/urlsession-data-for-request-urlrequest-delegate-async-throws-data-urlresponse-function-migration/58813)

<div class="topic-metadata">

**Author:** [@RandomHashTags](https://forums.swift.org/u/RandomHashTags)\
**Replies:** 9\
**Last updated:** [February 22, 2024, 7:47pm UTC](https://forums.swift.org/t/urlsession-data-for-request-urlrequest-delegate-async-throws-data-urlresponse-function-migration/58813 "2024-02-22T19:47:26Z")

</div>

Preface: I've been developing a Vapor Server in Swift 5.7 on my iMac, running the latest development binary (July 5th) on a linux machine (using AUR (en) - swift-bin-development). The method "data(for request: URLReques…

---

## [URLSession Implicit Cancellation using Async/Await Helper](https://forums.swift.org/t/urlsession-implicit-cancellation-using-async-await-helper/69230)

<div class="topic-metadata">

**Author:** [@pewe](https://forums.swift.org/u/pewe)\
**Replies:** 7\
**Last updated:** [January 4, 2024, 8:08am UTC](https://forums.swift.org/t/urlsession-implicit-cancellation-using-async-await-helper/69230 "2024-01-04T08:08:24Z")

</div>

We have a wrapper around a custom URLSession instance that is supposed to be deallocated in certain situations and then implicitly cancel all running network requests. When starting a request using async/await however, …

---

## [Single URLSession for all requests versus per request, performance](https://forums.swift.org/t/single-urlsession-for-all-requests-versus-per-request-performance/68002)

<div class="topic-metadata">

**Author:** [@Devarshi](https://forums.swift.org/u/Devarshi)\
**Replies:** 2\
**Last updated:** [October 23, 2023, 3:29pm UTC](https://forums.swift.org/t/single-urlsession-for-all-requests-versus-per-request-performance/68002 "2023-10-23T15:29:09Z")

</div>

In a legacy project which has both ObjC and Swift Code I noticed that for each request a new session was created: -(void)sendRequest { // Some configuration // New session is created for every request NSURLSession \*ses…

---

## [How to call URLSession Cache handler delegate method in async await?](https://forums.swift.org/t/how-to-call-urlsession-cache-handler-delegate-method-in-async-await/66473)

<div class="topic-metadata">

**Author:** [@kokotata421](https://forums.swift.org/u/kokotata421)\
**Replies:** 5\
**Last updated:** [August 2, 2023, 8:03am UTC](https://forums.swift.org/t/how-to-call-urlsession-cache-handler-delegate-method-in-async-await/66473 "2023-08-02T08:03:24Z")

</div>

Hello! I try to find the way to customize the caching response handler in URLSession async await methods. When I call the async await URLSession data method func data(for request: URLRequest, delegate: (URLSessionTaskD…

---

## [Does Task cancellation propagate to URLSessionTasks?](https://forums.swift.org/t/does-task-cancellation-propagate-to-urlsessiontasks/65041)

<div class="topic-metadata">

**Author:** [@mqrs](https://forums.swift.org/u/mqrs)\
**Replies:** 1\
**Last updated:** [May 18, 2023, 8:20am UTC](https://forums.swift.org/t/does-task-cancellation-propagate-to-urlsessiontasks/65041 "2023-05-18T08:20:09Z")

</div>

If I have a Swift Task like this: let task = Task { let (data, response) = try await URLSession.shared.data(from: URL(string: "https://some-image-url.com")!) // ... } And then I do task.cancel(), does URLSession au…

---

## [Putting a break on console warning](https://forums.swift.org/t/putting-a-break-on-console-warning/64092)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 6\
**Last updated:** [April 1, 2023, 7:03am UTC](https://forums.swift.org/t/putting-a-break-on-console-warning/64092 "2023-04-01T07:03:37Z")

</div>

I am getting this console warning: How do I put a breakpoint on it? It is not obvious what "this method" it's talking about.

---

## [Problem with GET-Request (NSURLErrorDomain: -1003)](https://forums.swift.org/t/problem-with-get-request-nsurlerrordomain-1003/60716)

<div class="topic-metadata">

**Author:** [@Timo](https://forums.swift.org/u/Timo)\
**Replies:** 2\
**Last updated:** [October 8, 2022, 4:06pm UTC](https://forums.swift.org/t/problem-with-get-request-nsurlerrordomain-1003/60716 "2022-10-08T16:06:31Z")

</div>

I face some issues performing a simple GET-Request. I defined a Struct whose variables are named equally to the API: struct CanteenItem: Codable { var id: Int var name: String ... } I then created a variab…

---

## [Are existential types Sendable?](https://forums.swift.org/t/are-existential-types-sendable/58946)

<div class="topic-metadata">

**Author:** [@Luke\_Lau](https://forums.swift.org/u/Luke_Lau)\
**Replies:** 5\
**Last updated:** [September 15, 2022, 7:19pm UTC](https://forums.swift.org/t/are-existential-types-sendable/58946 "2022-09-15T19:19:48Z")

</div>

I ran into an interesting warning from Xcode 14 beta 3 when trying to fetch some data for a UIImageView in a UIViewRepresentable, whilst using targeted concurrency checking: private struct MyView: UIViewRepresentable { …

---

## [How to further debug a simple HTTP request?](https://forums.swift.org/t/how-to-further-debug-a-simple-http-request/56931)

<div class="topic-metadata">

**Author:** [@Butanediol](https://forums.swift.org/u/Butanediol)\
**Replies:** 35\
**Last updated:** [June 13, 2022, 6:44pm UTC](https://forums.swift.org/t/how-to-further-debug-a-simple-http-request/56931 "2022-06-13T18:44:52Z")

</div>

I'm making a simple HTTP request towards an API. I extracted it as a script, simple like this: import Foundation #if canImport(FoundationNetworking) import FoundationNetworking† #endif let url = URL(string: "https://l…

---

## [How to check if one of URLSession tasks returned an error and if so stop code execution?](https://forums.swift.org/t/how-to-check-if-one-of-urlsession-tasks-returned-an-error-and-if-so-stop-code-execution/57525)

<div class="topic-metadata">

**Author:** [@artexhibit](https://forums.swift.org/u/artexhibit)\
**Replies:** 4\
**Last updated:** [May 24, 2022, 9:27am UTC](https://forums.swift.org/t/how-to-check-if-one-of-urlsession-tasks-returned-an-error-and-if-so-stop-code-execution/57525 "2022-05-24T09:27:06Z")

</div>

I need to make 2 API calls simultaneously. I have 2 URLs for the calls, and if one of the calls will return any error I want to stop all the code execution. How I tried to do it: I have a function called performReques…

---

## [URLSession downloadTask cannot configure timeout and also cannot downlaod with resume data](https://forums.swift.org/t/urlsession-downloadtask-cannot-configure-timeout-and-also-cannot-downlaod-with-resume-data/55654)

<div class="topic-metadata">

**Author:** [@WXGBridgeQ](https://forums.swift.org/u/WXGBridgeQ)\
**Replies:** 1\
**Last updated:** [March 1, 2022, 4:45pm UTC](https://forums.swift.org/t/urlsession-downloadtask-cannot-configure-timeout-and-also-cannot-downlaod-with-resume-data/55654 "2022-03-01T16:45:15Z")

</div>

Using URLSession downloadTask to download some file from URL, by setting timeoutIntervalForResource of the session configuration, and in urlSession(\_:task:didCompleteWithError:) delegate trying to get resumeData with NSU…

---

## [Controlling flow in task based URLSession](https://forums.swift.org/t/controlling-flow-in-task-based-urlsession/51185)

<div class="topic-metadata">

**Author:** [@Daniel\_Steinberg](https://forums.swift.org/u/Daniel_Steinberg)\
**Replies:** 2\
**Last updated:** [August 14, 2021, 11:53am UTC](https://forums.swift.org/t/controlling-flow-in-task-based-urlsession/51185 "2021-08-14T11:53:31Z")

</div>

Hi, We can do quite a bit with AsyncSequences, AsyncStreams, and the async APIs that we could do with Combine. As has been noted, one of the things we can't easily do is regulate flow. I apologize if this has been aske…

---

## [Caching TLS handshake when using URLSession](https://forums.swift.org/t/caching-tls-handshake-when-using-urlsession/50323)

<div class="topic-metadata">

**Author:** [@\_vladi](https://forums.swift.org/u/_vladi)\
**Replies:** 5\
**Last updated:** [July 13, 2021, 9:15am UTC](https://forums.swift.org/t/caching-tls-handshake-when-using-urlsession/50323 "2021-07-13T09:15:17Z")

</div>

Hello guys, I want to know if there is any API which could configure my URLSession object such that the TLS handshake is cached between two requests for a long period of time. From my observations so far, the TLS handsh…

---

## [Is there an equivalent to dataTaskPublisher for uploadTask](https://forums.swift.org/t/is-there-an-equivalent-to-datataskpublisher-for-uploadtask/41322)

<div class="topic-metadata">

**Author:** [@jsoneaday](https://forums.swift.org/u/jsoneaday)\
**Replies:** 1\
**Last updated:** [October 20, 2020, 3:33pm UTC](https://forums.swift.org/t/is-there-an-equivalent-to-datataskpublisher-for-uploadtask/41322 "2020-10-20T15:33:05Z")

</div>

I need to switch my thread to DispatchQueue.main to get back on UI thread, but I need to do it in a post with payload. Is there an equivalent to dataTaskPublisher for uploadTask or some other mechanism to do this?

---

## [How to only display selected crypto coins from an API call](https://forums.swift.org/t/how-to-only-display-selected-crypto-coins-from-an-api-call/33860)

<div class="topic-metadata">

**Author:** [@TAMustafa](https://forums.swift.org/u/TAMustafa)\
**Replies:** 2\
**Last updated:** [February 16, 2020, 6:02pm UTC](https://forums.swift.org/t/how-to-only-display-selected-crypto-coins-from-an-api-call/33860 "2020-02-16T18:02:49Z")

</div>

As my first Swift app I like to build a crypto currency converter using Swift UI and struggle to find a way to filter out selected crypto coins from an API call. For example: The following API call returns the top 100 …

---

## [\[Linux\] Swift 5.1 URLSession unable to handle multiple concurrent connections](https://forums.swift.org/t/linux-swift-5-1-urlsession-unable-to-handle-multiple-concurrent-connections/29441)

<div class="topic-metadata">

**Author:** [@mman](https://forums.swift.org/u/mman)\
**Replies:** 4\
**Last updated:** [November 5, 2019, 12:42am UTC](https://forums.swift.org/t/linux-swift-5-1-urlsession-unable-to-handle-multiple-concurrent-connections/29441 "2019-11-05T00:42:07Z")

</div>

Hi guys, sorry if this is a wrong place to bring this. I am using SwiftyRequest under official Linux docker image for Swift 5.1 and getting ton of timeouts (error 1001) when firing up multiple simultaneous POST requests…

---

## [Fatal error: seekInputStream(to:) is not yet implemented in URLSession](https://forums.swift.org/t/fatal-error-seekinputstream-to-is-not-yet-implemented-in-urlsession/17587)

<div class="topic-metadata">

**Author:** [@woodcrust](https://forums.swift.org/u/woodcrust)\
**Replies:** 5\
**Last updated:** [April 25, 2019, 7:10pm UTC](https://forums.swift.org/t/fatal-error-seekinputstream-to-is-not-yet-implemented-in-urlsession/17587 "2019-04-25T19:10:15Z")

</div>

Hello, sorry, my english is very bad... I use URLSession just inside my own library written in pure swift with Foundation for Linux(Debian) without any frameworks. And sometimes I have this error Fatal error: seekInput…

[Next page](https://forums.swift.org/tag/urlsession/176.md?match_all_tags=true&page=1&tags%5B%5D=urlsession)
