Request body shows as empty in Proxyman when using Atlantis
Description
Some requests, not all, show as having an empty body in Proxyman when using Atlantis framework in an iOS project
Steps to Reproduce
- Add Atlantis to an iOS project
- Initialise Atlantis:
[Atlantis startWithHostName:nil shouldCaptureWebSocketTraffic: NO]; - Make requests using NSURLSession;
Current Behavior
Sometimes the request shows an empty body, where there was data in the body. The response do show a body. This is not for all requests. The same request might or might not show a body when repeated/
Expected Behavior
All requests that have body data should show the body data in Proxyman.
Environment
- App version: e.g Proxyman 5.1.1
- macOS version: e.g macOS Sonoma 14.4
- Atlantis 1.24.0
Maybe the response is cached on your client, so there is no body to capture and send to Proxyman.
Can you verify it?
You can test it by using no caching policy from URLSession
It is the request that has the empty body, not the response.
@mborsten can you share with me the log or any useful information that we can check?
For example:
- What Method, URL, and the Body Type (JSON, Data, Image, PDF, multipart, or Streaming Body?)
- Websocket or normal HTTPS ?
- The Content-Type Header of the Request If you don't mind, please export this request as a ProxymanLog and share it with me at [email protected]
I'd like to investigate it 👍
I'm having the same issue. This was working a week or two ago. Not sure what changed.
I even tried to rollback a caouple versions of Proxyman and Atlantis to no avail. Perhaps it's swizzling issue. Proxyman v4.16.0 from Jan 7 Atlantis v1.22.0
I think this is failing in atlantis, I've set a berakpoint and I can see that the body in the request of the message is nil. In the backend I do receive the body, so the request is OK:
@mborsten I guess the issue is from the Method Swizzling.
If you can set the breakpoint, can you trace back what URLSessionURLTask's method is called? I suppose that it's not URLSession.dataTaskWithURL: or URLSession.dataTaskWithRequest 🤔
May I ask:
- What is the Content-Type of the Request?
The content-type is 'application/json', I will try to get more information for you
@mborsten it's quite simple: J
- Just right-click on this request -> Export -> ProxymanLog and share with me at [email protected]
- and If you can set the Breakpoint as your last comment, please trace back to what URLSession's method is called.
I will try to investigate it 👍
@NghiaTranUIT method being called is URLSession.uploadTaskWithStreamedRequest
Nice. This API hasn't been implemented with the Method Swizzling yet. Let me support it 👍
@NghiaTranUIT Any update on when this will be added?
Not yet @mborsten I'm working on it now 👍
May I ask that you need to capture traffic from URLSession.uploadTaskWithStreamedRequest too ?
@mooshee @mborsten may I ask:
- When using
URLSession.uploadTaskWithStreamedRequest. Do you provide the Request Body via this delegate method: https://developer.apple.com/documentation/foundation/urlsessiontaskdelegate/1410001-urlsession ? - Or from
request.httpBody = data🤔
if you provide the body via: request.httpBody = data I can make it work and send you a Beta build.
If it's from the delegate, I'm still looking for a solution. I tried, but It's hard to inject into its runtime.
I'm using [request setHTTPBodyStream: stream];
@mborsten I'm not sure how you can use request.httpBodyStream = ... while using URLSession.uploadTaskWithStreamedRequest() ?
because I get this error:
The request of a upload task should not contain a body or a body stream, use `upload(for:fromFile:)`, `upload(for:from:)`, or supply the body stream through the `urlSession(_:needNewBodyStreamForTask:)` delegate method.
The body is ignored and other tools can't capture it.