-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve non-standard/unparseable query strings as-is in snippet output
This is particularly notable for cases like the &&& repro here, but is also clearly visible in cases like ?a=b&c, which would often become something more like '?a=b&c='. This only applies when the queryString in the HAR is empty, which will be rare, but HTTP Toolkit (and others) can use this to leave that blank and send only the raw URL to preserve formatting at the cost of the losing the nice structure query param setting code in the output.
- Loading branch information
Showing
37 changed files
with
348 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 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,6 @@ | ||
CURL *hnd = curl_easy_init(); | ||
|
||
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET"); | ||
curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har?&&&"); | ||
|
||
CURLcode ret = curl_easy_perform(hnd); |
This file contains 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,3 @@ | ||
(require '[clj-http.client :as client]) | ||
|
||
(client/get "http://mockbin.com/har?&&&") |
12 changes: 12 additions & 0 deletions
12
test/fixtures/output/csharp/httpclient/unparseable-query.cs
This file contains 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,12 @@ | ||
var client = new HttpClient(); | ||
var request = new HttpRequestMessage | ||
{ | ||
Method = HttpMethod.Get, | ||
RequestUri = new Uri("http://mockbin.com/har?&&&"), | ||
}; | ||
using (var response = await client.SendAsync(request)) | ||
{ | ||
response.EnsureSuccessStatusCode(); | ||
var body = await response.Content.ReadAsStringAsync(); | ||
Console.WriteLine(body); | ||
} |
This file contains 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,3 @@ | ||
var client = new RestClient("http://mockbin.com/har?&&&"); | ||
var request = new RestRequest(Method.GET); | ||
IRestResponse response = client.Execute(request); |
This file contains 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,23 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"io" | ||
) | ||
|
||
func main() { | ||
|
||
url := "http://mockbin.com/har?&&&" | ||
|
||
req, _ := http.NewRequest("GET", url, nil) | ||
|
||
res, _ := http.DefaultClient.Do(req) | ||
|
||
defer res.Body.Close() | ||
body, _ := io.ReadAll(res.Body) | ||
|
||
fmt.Println(res) | ||
fmt.Println(string(body)) | ||
|
||
} |
This file contains 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,2 @@ | ||
GET /har?&&& HTTP/1.1 | ||
Host: mockbin.com |
This file contains 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,8 @@ | ||
AsyncHttpClient client = new DefaultAsyncHttpClient(); | ||
client.prepare("GET", "http://mockbin.com/har?&&&") | ||
.execute() | ||
.toCompletableFuture() | ||
.thenAccept(System.out::println) | ||
.join(); | ||
|
||
client.close(); |
This file contains 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,6 @@ | ||
HttpRequest request = HttpRequest.newBuilder() | ||
.uri(URI.create("http://mockbin.com/har?&&&")) | ||
.method("GET", HttpRequest.BodyPublishers.noBody()) | ||
.build(); | ||
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); | ||
System.out.println(response.body()); |
This file contains 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,8 @@ | ||
OkHttpClient client = new OkHttpClient(); | ||
|
||
Request request = new Request.Builder() | ||
.url("http://mockbin.com/har?&&&") | ||
.get() | ||
.build(); | ||
|
||
Response response = client.newCall(request).execute(); |
This file contains 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,2 @@ | ||
HttpResponse<String> response = Unirest.get("http://mockbin.com/har?&&&") | ||
.asString(); |
This file contains 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,9 @@ | ||
import axios from "axios"; | ||
|
||
const options = {method: 'GET', url: 'http://mockbin.com/har?&&&'}; | ||
|
||
axios.request(options).then(function (response) { | ||
console.log(response.data); | ||
}).catch(function (error) { | ||
console.error(error); | ||
}); |
This file contains 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,6 @@ | ||
const options = {method: 'GET'}; | ||
|
||
fetch('http://mockbin.com/har?&&&', options) | ||
.then(response => response.json()) | ||
.then(response => console.log(response)) | ||
.catch(err => console.error(err)); |
11 changes: 11 additions & 0 deletions
11
test/fixtures/output/javascript/jquery/unparseable-query.js
This file contains 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,11 @@ | ||
const settings = { | ||
"async": true, | ||
"crossDomain": true, | ||
"url": "http://mockbin.com/har?&&&", | ||
"method": "GET", | ||
"headers": {} | ||
}; | ||
|
||
$.ajax(settings).done(function (response) { | ||
console.log(response); | ||
}); |
This file contains 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,14 @@ | ||
const data = null; | ||
|
||
const xhr = new XMLHttpRequest(); | ||
xhr.withCredentials = true; | ||
|
||
xhr.addEventListener("readystatechange", function () { | ||
if (this.readyState === this.DONE) { | ||
console.log(this.responseText); | ||
} | ||
}); | ||
|
||
xhr.open("GET", "http://mockbin.com/har?&&&"); | ||
|
||
xhr.send(data); |
This file contains 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,8 @@ | ||
val client = OkHttpClient() | ||
|
||
val request = Request.Builder() | ||
.url("http://mockbin.com/har?&&&") | ||
.get() | ||
.build() | ||
|
||
val response = client.newCall(request).execute() |
This file contains 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,9 @@ | ||
var axios = require("axios").default; | ||
|
||
var options = {method: 'GET', url: 'http://mockbin.com/har?&&&'}; | ||
|
||
axios.request(options).then(function (response) { | ||
console.log(response.data); | ||
}).catch(function (error) { | ||
console.error(error); | ||
}); |
This file contains 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,10 @@ | ||
const fetch = require('node-fetch'); | ||
|
||
let url = 'http://mockbin.com/har?&&&'; | ||
|
||
let options = {method: 'GET'}; | ||
|
||
fetch(url, options) | ||
.then(res => res.json()) | ||
.then(json => console.log(json)) | ||
.catch(err => console.error('error:' + err)); |
This file contains 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,24 @@ | ||
const http = require("http"); | ||
|
||
const options = { | ||
"method": "GET", | ||
"hostname": "mockbin.com", | ||
"port": null, | ||
"path": "/har?&&&", | ||
"headers": {} | ||
}; | ||
|
||
const req = http.request(options, function (res) { | ||
const chunks = []; | ||
|
||
res.on("data", function (chunk) { | ||
chunks.push(chunk); | ||
}); | ||
|
||
res.on("end", function () { | ||
const body = Buffer.concat(chunks); | ||
console.log(body.toString()); | ||
}); | ||
}); | ||
|
||
req.end(); |
This file contains 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,9 @@ | ||
const request = require('request'); | ||
|
||
const options = {method: 'GET', url: 'http://mockbin.com/har?&&&'}; | ||
|
||
request(options, function (error, response, body) { | ||
if (error) throw new Error(error); | ||
|
||
console.log(body); | ||
}); |
This file contains 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,9 @@ | ||
const unirest = require("unirest"); | ||
|
||
const req = unirest("GET", "http://mockbin.com/har?&&&"); | ||
|
||
req.end(function (res) { | ||
if (res.error) throw new Error(res.error); | ||
|
||
console.log(res.body); | ||
}); |
18 changes: 18 additions & 0 deletions
18
test/fixtures/output/objc/nsurlsession/unparseable-query.m
This file contains 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,18 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har?&&&"] | ||
cachePolicy:NSURLRequestUseProtocolCachePolicy | ||
timeoutInterval:10.0]; | ||
[request setHTTPMethod:@"GET"]; | ||
|
||
NSURLSession *session = [NSURLSession sharedSession]; | ||
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request | ||
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { | ||
if (error) { | ||
NSLog(@"%@", error); | ||
} else { | ||
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; | ||
NSLog(@"%@", httpResponse); | ||
} | ||
}]; | ||
[dataTask resume]; |
This file contains 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,9 @@ | ||
open Cohttp_lwt_unix | ||
open Cohttp | ||
open Lwt | ||
|
||
let uri = Uri.of_string "http://mockbin.com/har?&&&" in | ||
|
||
Client.call `GET uri | ||
>>= fun (res, body_stream) -> | ||
(* Do stuff with the result *) |
This file contains 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,24 @@ | ||
<?php | ||
|
||
$curl = curl_init(); | ||
|
||
curl_setopt_array($curl, [ | ||
CURLOPT_URL => 'http://mockbin.com/har?&&&', | ||
CURLOPT_RETURNTRANSFER => true, | ||
CURLOPT_ENCODING => '', | ||
CURLOPT_MAXREDIRS => 10, | ||
CURLOPT_TIMEOUT => 30, | ||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, | ||
CURLOPT_CUSTOMREQUEST => 'GET', | ||
]); | ||
|
||
$response = curl_exec($curl); | ||
$err = curl_error($curl); | ||
|
||
curl_close($curl); | ||
|
||
if ($err) { | ||
echo 'cURL Error #:' . $err; | ||
} else { | ||
echo $response; | ||
} |
This file contains 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,13 @@ | ||
<?php | ||
|
||
$request = new HttpRequest(); | ||
$request->setUrl('http://mockbin.com/har?&&&'); | ||
$request->setMethod(HTTP_METH_GET); | ||
|
||
try { | ||
$response = $request->send(); | ||
|
||
echo $response->getBody(); | ||
} catch (HttpException $ex) { | ||
echo $ex; | ||
} |
This file contains 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,11 @@ | ||
<?php | ||
|
||
$client = new http\Client; | ||
$request = new http\Client\Request; | ||
|
||
$request->setRequestUrl('http://mockbin.com/har?&&&'); | ||
$request->setRequestMethod('GET'); | ||
$client->enqueue($request)->send(); | ||
$response = $client->getResponse(); | ||
|
||
echo $response->getBody(); |
1 change: 1 addition & 0 deletions
1
test/fixtures/output/powershell/restmethod/unparseable-query.ps1
This file contains 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 @@ | ||
$response = Invoke-RestMethod -Uri 'http://mockbin.com/har?&&&' -Method GET |
1 change: 1 addition & 0 deletions
1
test/fixtures/output/powershell/webrequest/unparseable-query.ps1
This file contains 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 @@ | ||
$response = Invoke-WebRequest -Uri 'http://mockbin.com/har?&&&' -Method GET |
This file contains 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,10 @@ | ||
import http.client | ||
|
||
conn = http.client.HTTPConnection("mockbin.com") | ||
|
||
conn.request("GET", "/har?&&&") | ||
|
||
res = conn.getresponse() | ||
data = res.read() | ||
|
||
print(data.decode("utf-8")) |
This file contains 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,7 @@ | ||
import requests | ||
|
||
url = "http://mockbin.com/har?&&&" | ||
|
||
response = requests.get(url) | ||
|
||
print(response.text) |
This file contains 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,7 @@ | ||
library(httr) | ||
|
||
url <- "http://mockbin.com/har?&&&" | ||
|
||
response <- VERB("GET", url, content_type("application/octet-stream")) | ||
|
||
content(response, "text") |
This file contains 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,11 @@ | ||
require 'uri' | ||
require 'net/http' | ||
|
||
url = URI("http://mockbin.com/har?&&&") | ||
|
||
http = Net::HTTP.new(url.host, url.port) | ||
|
||
request = Net::HTTP::Get.new(url) | ||
|
||
response = http.request(request) | ||
puts response.read_body |
Oops, something went wrong.