-
Notifications
You must be signed in to change notification settings - Fork 5
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
Added an URLRequest extension to generate cURL commands #222
base: develop
Are you sure you want to change the base?
Conversation
to generate a CURL command including http method, http headers and the http body
if let httpBody = httpBody, | ||
let httpBodyString = String(data: httpBody, encoding: .utf8), | ||
!httpBodyString.isEmpty { | ||
options.append("-d \"\(httpBodyString)\"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently interferes with the header Content-Length and needs further investigation. Maybe Content-Length should be skipped when data are being transmitted.
Example taken from example application:
curl -X POST -H "Content-Length: 30" -d "This is just a simple payload" https://httpbin.org/post
When omitting the Content-Length header request runs smoothly
curl -X POST -d "This is just a simple payload" https://httpbin.org/post
expect(hasCurlAsPrefix) == true | ||
} | ||
|
||
it("returns a curl command matching the request URL") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo: false description
This is how it could look like. (fyi: @brototyp @lukaswuerzburger) Will add an image from the system provided ones: https://developer.apple.com/design/resources/ |
This PR adds an extension for URLRequest to transform a request to a cURL command. So far the cURL extension is not hooked up to any UI component since I'm not sure where this would fit the best. I'm open for any input on this one!
What do you think adding a
copy as cURL
functionality on this screen? Maybe even just as an UIActivity to the UIActivityViewController.