Added an URLRequest extension to generate cURL commands#222
Draft
pstued wants to merge 2 commits into
Draft
Conversation
to generate a CURL command including http method, http headers and the http body
pstued
commented
Mar 14, 2021
| if let httpBody = httpBody, | ||
| let httpBodyString = String(data: httpBody, encoding: .utf8), | ||
| !httpBodyString.isEmpty { | ||
| options.append("-d \"\(httpBodyString)\"") |
Member
Author
There was a problem hiding this comment.
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
pstued
commented
Mar 14, 2021
| expect(hasCurlAsPrefix) == true | ||
| } | ||
|
|
||
| it("returns a curl command matching the request URL") { |
Member
Author
|
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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 cURLfunctionality on this screen? Maybe even just as an UIActivity to the UIActivityViewController.