Skip to content

Debugging HTTPBody #749

Open
Open
@hactar

Description

@hactar

Question

I'm trying to do what I do in most of my apps: add a button that, when tapped, copies request url, request headers, request body, response headers, response body, etc to the clipboard so that it can be shared with developers for further debugging. This is used when a user has issues with failing url requests on a device the developer might not have access to.

Typically I use https://github.com/pmusolino/Wormholy or https://github.com/kean/Pulse for this as they take care of all this for me. But when used with swift-openapi-urlsession, results are mixed: while the requests are listed, and contain most information such as headers and parameters, the tools have troubles picking up request data, and sometimes even response data. Taking a look at the code of swift-openapi-urlsession, I assume this is because swift-openapi-urlsession does fancy bi-directional stream sending and receiving instead of the basic way that is more commonly used?

So I set myself a breakpoint at func bidirectionalStreamingRequest to po requestBody - but this doesn't provide any useful debug representation. I then thought of using po String(collecting: requestBody!, upTo: 1024) but that fails too because collecting is an async function, so doesn't play well with lldb (or at least I can't figure out how to quickly do so).

Could something be done to make it easier to debug HTTPBody - for example a non async function that spits out the HTTPBody to be used for debugging only?

Would a PR for swift-openapi-urlsession that optionally just uses the basic non streaming versions of sending/receiving data be a welcome addition, so that tools such as wormholy or pulse would work? I'm not sure how feasible it is to add bi-directional streaming support to wormholy or pulse... Or is the issue somewhere else and do I have it all wrong? :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/supportAdopter support requests.status/triageCollecting information required to triage the issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions