forked from Kong/httpsnippet
-
Notifications
You must be signed in to change notification settings - Fork 7
feat(rebase): updating our fork with the latest upstream #180
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
Merged
Merged
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
66baca6
Total Overhaul (but with all the same fixtures!) (#248)
dimitropoulos c7eae4c
fix: case where if `postData.params` is missing some targets crash (#…
erunion 998e403
fix: compatibility issues on node 14 with `Object.hasOwn()` (#252)
erunion f64080d
fix: typo in the httpie `style` option not being correctly applied (#…
erunion cd4bb4c
fix: axios targets not sending `x-www-form-urlencoded` properly (#255)
erunion 62d158d
feat: addition of a PHP target for Guzzle (#253)
erunion 0e0728a
Add Github Build Workflow (#250) (#251)
filfreire 411844f
feat: native upload support in python `requests` snippets (#259)
erunion 3119335
fix: `multipart/form-data` header issues with node/js fetch targets (…
erunion 5e8f161
fix: headers not being properly applied to R httr snippets (#263)
erunion 8ca9771
Fix build workflow dispatch rules (#265)
filfreire 97731b1
Chore: Remove travis links (#266)
filfreire 91a872b
fix: issue where query strings in R wouldn't be properly concatenated…
erunion d4bebe4
add header namesspace to prevent header errors (#247)
da711e9
fix: stop implicitly coercing warning in Swift snippet generator (#195)
irajtaghlidi 3c9e6a6
fix: clj-http handling of literal null JSON bodies (#283)
dimitropoulos 7da8c97
fix: prevent crash in Swift/Objc with checking length of input body p…
irajtaghlidi 12aa17e
fix: cUrl target should encode x-www-form-urlencoded post data params…
jgiovaresco 2c8b558
feat: Add support for insecureSkipVerify (#285)
dimitropoulos 735e69a
feat: implementing cleaner handling of JSON in cURL snippets (#256)
erunion 8ea7e13
chore: minor cleanup (#286)
erunion 19f1b2f
feat: use curl's --compressed option for requests that accept it (#287)
dimitropoulos 2f7525d
feat: make Python snippets simpler, clearer & more consistent (#288)
dimitropoulos 4ac5253
feat: change the default response code for Python Requests (#181)
jgiovaresco a92b4fc
feat: PHP JSON body encoding (#291)
dimitropoulos 5ec84e0
Async/Await (top level) support in JavaScript snippets (#292)
dimitropoulos 1dda869
Exclude package.json from build to fix output paths (#294)
pimterry 911ab77
Fix crash when building nsurlsession snippets for empty params (#295)
pimterry cd2a0cc
removes `require 'openssl'` from ruby target (no longer needed) (#296)
dimitropoulos bf019b3
Escape quotes in headers correctly in all languages (#289)
pimterry 7c00d05
updates README (#299)
dimitropoulos cee79a5
ioutil -> io (deprecated) (#305)
f289c7d
Merge remote-tracking branch 'upstream/master' into rebase/upstream
erunion 20da8c8
chore: undoing unwanted changes
erunion 69141c7
chore: revert more unwanted changes
erunion 1d3265e
chore: reverting more unwanted changes
erunion 903367e
fix: fixing broken test snapshots and libcurl not escaping
erunion 08fc41e
fix: a bunch of broken tests
erunion 1d8b372
fix: removing dead code
erunion 9def8af
fix: remove support for `insecureSkipVerify` as we dont need or want it
erunion ba3a0b7
fix: removing top-level await changes for axios
erunion c8c0afd
fix: revert top-level await changes for js:fetch
erunion 9b8e863
fix: remove some problematic changes to `node:request`
erunion eb26f40
fix: retaining line trimming in powershell snippets
erunion 6b49e04
fix: bug in php snippets where booleans were casted to null
erunion 5d083ab
fix: revert problematic changes to python:requests
erunion 0171351
fix: revert more unwanted changes
erunion 7b85447
chore: temporarily skipping the integration suite
erunion f6c9d4f
fix: broken snapshot
erunion 5a328a6
fix: disabling the integration suite from being run without inside do…
erunion 5c4c8c4
fix: integration suite
erunion 5e56dbc
fix: integration suite
erunion File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { escapeString } from './escape'; | ||
|
|
||
| describe('Escape methods', () => { | ||
| describe('escapeString', () => { | ||
| it('does nothing to a safe string', () => { | ||
| expect(escapeString('hello world')).toBe('hello world'); | ||
| }); | ||
|
|
||
| it('escapes double quotes by default', () => { | ||
| expect(escapeString('"hello world"')).toBe('\\"hello world\\"'); | ||
| }); | ||
|
|
||
| it('escapes newlines by default', () => { | ||
| expect(escapeString('hello\r\nworld')).toBe('hello\\r\\nworld'); | ||
| }); | ||
|
|
||
| it('escapes backslashes', () => { | ||
| expect(escapeString('hello\\world')).toBe('hello\\\\world'); | ||
| }); | ||
|
|
||
| it('escapes unrepresentable characters', () => { | ||
| expect( | ||
| escapeString('hello \u0000') // 0 = ASCII 'null' character | ||
| ).toBe('hello \\u0000'); | ||
| }); | ||
| }); | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| export interface EscapeOptions { | ||
| /** | ||
| * The delimiter that will be used to wrap the string (and so must be escaped | ||
| * when used within the string). | ||
| * Defaults to " | ||
| */ | ||
| delimiter?: string; | ||
|
|
||
| /** | ||
| * The char to use to escape the delimiter and other special characters. | ||
| * Defaults to \ | ||
| */ | ||
| escapeChar?: string; | ||
|
|
||
| /** | ||
| * Whether newlines (\n and \r) should be escaped within the string. | ||
| * Defaults to true. | ||
| */ | ||
| escapeNewlines?: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * Escape characters within a value to make it safe to insert directly into a | ||
| * snippet. Takes options which define the escape requirements. | ||
| * | ||
| * This is closely based on the JSON-stringify string serialization algorithm, | ||
| * but generalized for other string delimiters (e.g. " or ') and different escape | ||
| * characters (e.g. Powershell uses `) | ||
| * | ||
| * See https://tc39.es/ecma262/multipage/structured-data.html#sec-quotejsonstring | ||
| * for the complete original algorithm. | ||
| */ | ||
| export function escapeString(rawValue: any, options: EscapeOptions = {}) { | ||
| const { delimiter = '"', escapeChar = '\\', escapeNewlines = true } = options; | ||
|
|
||
| const stringValue = rawValue.toString(); | ||
|
|
||
| return [...stringValue] | ||
| .map(c => { | ||
| if (c === '\b') { | ||
| return `${escapeChar}b`; | ||
| } else if (c === '\t') { | ||
| return `${escapeChar}t`; | ||
| } else if (c === '\n') { | ||
| if (escapeNewlines) { | ||
| return `${escapeChar}n`; | ||
| } | ||
|
|
||
| return c; // Don't just continue, or this is caught by < \u0020 | ||
| } else if (c === '\f') { | ||
| return `${escapeChar}f`; | ||
| } else if (c === '\r') { | ||
| if (escapeNewlines) { | ||
| return `${escapeChar}r`; | ||
| } | ||
|
|
||
| return c; // Don't just continue, or this is caught by < \u0020 | ||
| } else if (c === escapeChar) { | ||
| return escapeChar + escapeChar; | ||
| } else if (c === delimiter) { | ||
| return escapeChar + delimiter; | ||
| } else if (c < '\u0020' || c > '\u007E') { | ||
| // Delegate the trickier non-ASCII cases to the normal algorithm. Some of these | ||
| // are escaped as \uXXXX, whilst others are represented literally. Since we're | ||
| // using this primarily for header values that are generally (though not 100% | ||
| // strictly?) ASCII-only, this should almost never happen. | ||
| return JSON.stringify(c).slice(1, -1); | ||
| } | ||
|
|
||
| return c; | ||
| }) | ||
| .join(''); | ||
| } | ||
|
|
||
| /** | ||
| * Make a string value safe to insert literally into a snippet within single quotes, | ||
| * by escaping problematic characters, including single quotes inside the string, | ||
| * backslashes, newlines, and other special characters. | ||
| * | ||
| * If value is not a string, it will be stringified with .toString() first. | ||
| */ | ||
| export const escapeForSingleQuotes = (value: any) => escapeString(value, { delimiter: "'" }); | ||
|
|
||
| /** | ||
| * Make a string value safe to insert literally into a snippet within double quotes, | ||
| * by escaping problematic characters, including double quotes inside the string, | ||
| * backslashes, newlines, and other special characters. | ||
| * | ||
| * If value is not a string, it will be stringified with .toString() first. | ||
| */ | ||
| export const escapeForDoubleQuotes = (value: any) => escapeString(value, { delimiter: '"' }); |
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| (require '[clj-http.client :as client]) | ||
|
|
||
| (client/get "https://httpbin.org/headers" {:headers {:x-foo "Bar" | ||
| :x-bar "Foo"} | ||
| :x-bar "Foo" | ||
| :quoted-value "\"quoted\" 'string'"} | ||
| :accept :json}) |
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| var client = new RestClient("https://httpbin.org/anything"); | ||
| var request = new RestRequest(Method.POST); | ||
| request.AddHeader("content-type", "application/json"); | ||
| request.AddParameter("application/json", "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}", ParameterType.RequestBody); | ||
| request.AddParameter("application/json", "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":[]}],\"boolean\":false}", ParameterType.RequestBody); | ||
| IRestResponse response = client.Execute(request); |
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
Oops, something went wrong.
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.
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.
Changed to this part of this fixture to an empty array because the empty object was throwing off some of our unit test assertions.