I’m having a very odd problem in which my URLSession response works the first time, but almost always fails on subsequent calls. It’s taken me forever to debug because I needed to examine the response headers to determine anything at all. I used Proxyman based on a recommendation from Donny Wals -- https://www.donnywals.com/debugging-network-traffic-with-proxyman/ -- and — as far as I can tell — the only differences between the calls is that the first call returns:
HTTP/1.1 200 OK
Date: Tue, 06 Jun 2023 14:06:08 GMT
Server: Apache
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control
Vary: Accept-Encoding,User-Agent
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Content-Encoding: gzip
Set-Cookie: PHPSESSID=d10701af2da595b698c57f183e76a709; path=/
Upgrade: h2
Connection: Upgrade, Keep-Alive
Keep-Alive: timeout=5, max=100
Transfer-Encoding: chunked
While subsequent calls return different values for Keep-Alive and Connection (and they’re returned in a different order):
Second call same as first except:
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Third Call same as first and second except:
Upgrade: h2
Connection: Upgrade, Keep-Alive
Keep-Alive: timeout=5, max=100
The subsequent calls also do not return the Set-Cookie value, and the Upgrade value appears sometimes but not others.
All three return 200 OK, but my code is failing on this step:
guard let (data, response) = try? await session.data(for: request),
let httpResponse = response as? HTTPURLResponse,
httpResponse.statusCode == 200
else {
logger.debug("Failed to receive valid response and/or data.")
throw MyError.missingData
}
This code is taken directly from the Earthquakes project at Apple (although I modified it slightly to send a POST to my API, which seems to work fine).
What's even more frustrating is that the second and third call immediately return the correct JSON data (all formatted fine, etc.) just like the first call, so I cannot understand why they fail.
I am completely stumped and hoping someone might have some idea of what I can do here, or even how I can debug better.
Thanks immensely for any help you can provide.
Post
Replies
Boosts
Views
Activity
This doesn't seem like an edge case design issue, so I can't imagine why I'm unable to get it to work and / or find a solution.
I want to have an image at the top of the view, below that a list of items, and some text below the list.
Regardless of what I attempt, the List disappears. I've tried using Section(header: x, footer: y) inside the List, but that completely throws everything out of whack, plus it's not really what I want to do; the Section becomes clickable and allows the contents to be hidden. (And, regardless, the Section footer is never displayed.)
Can anyone point me in the right direction here? Am I just attacking this problem completely incorrectly?
Example ContentView followed by extracted ListView. (The HeaderView is simply an Image and the FooterView is simply some Text blocks. Nothing complicated at all.)
var body: some View {
		ZStack{
Color.themeBackgroundColor
.edgesIgnoringSafeArea(.all)
VStack{
ScrollView{
HeaderView()
ListView()
FooterView()
}
}
}
}
struct ListView: View {
		var body: some View{
				List{
						ForEach(items) { title in
								Text(title.title)
						}
				}
				.listStyle(SidebarListStyle())
		}
}
I'm trying to duplicate some of the functionality of the Emoji Rangers widget in my app.
The Emoji Rangers app uses game:///panda and game:///egghead for deep-linking to specific characters.
But for the life of me I cannot determine how the app is registering the game:/// URL scheme.
We're supposed to register those in the URL Types section of the Info tab of the project, but for the demo app (which works) there is nothing there.
Did Apple do something with Simulator / Xcode to hijack that specific URL scheme? Or am I missing something somewhere?
I'm trying to allow my iOS 14 WidgetKit to deep link to a specific ViewController in my app. The problem is that my app is built in UIKit and not SwiftUI, so I have an AppDelegate. Does that mean it's impossible?