Skip to content

Commit 5e8f161

Browse files
fix: headers not being properly applied to R httr snippets (#263)
Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>
1 parent 3119335 commit 5e8f161

38 files changed

Lines changed: 63 additions & 30 deletions

File tree

src/fixtures/requests/headers.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
{
1010
"name": "x-foo",
1111
"value": "Bar"
12+
},
13+
{
14+
"name": "x-bar",
15+
"value": "Foo"
1216
}
1317
]
1418
}

src/targets/c/libcurl/fixtures/headers.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har");
66
struct curl_slist *headers = NULL;
77
headers = curl_slist_append(headers, "accept: application/json");
88
headers = curl_slist_append(headers, "x-foo: Bar");
9+
headers = curl_slist_append(headers, "x-bar: Foo");
910
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
1011

1112
CURLcode ret = curl_easy_perform(hnd);
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(require '[clj-http.client :as client])
22

3-
(client/get "http://mockbin.com/har" {:headers {:x-foo "Bar"}
3+
(client/get "http://mockbin.com/har" {:headers {:x-foo "Bar"
4+
:x-bar "Foo"}
45
:accept :json})

src/targets/csharp/httpclient/fixtures/headers.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
{
88
{ "accept", "application/json" },
99
{ "x-foo", "Bar" },
10+
{ "x-bar", "Foo" },
1011
},
1112
};
1213
using (var response = await client.SendAsync(request))

src/targets/csharp/restsharp/fixtures/headers.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
var request = new RestRequest(Method.GET);
33
request.AddHeader("accept", "application/json");
44
request.AddHeader("x-foo", "Bar");
5+
request.AddHeader("x-bar", "Foo");
56
IRestResponse response = client.Execute(request);

src/targets/go/native/fixtures/headers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func main() {
1414

1515
req.Header.Add("accept", "application/json")
1616
req.Header.Add("x-foo", "Bar")
17+
req.Header.Add("x-bar", "Foo")
1718

1819
res, _ := http.DefaultClient.Do(req)
1920

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
GET /har HTTP/1.1
22
Accept: application/json
33
X-Foo: Bar
4+
X-Bar: Foo
45
Host: mockbin.com
56

src/targets/java/asynchttp/fixtures/headers.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
client.prepare("GET", "http://mockbin.com/har")
33
.setHeader("accept", "application/json")
44
.setHeader("x-foo", "Bar")
5+
.setHeader("x-bar", "Foo")
56
.execute()
67
.toCompletableFuture()
78
.thenAccept(System.out::println)

src/targets/java/nethttp/fixtures/headers.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.uri(URI.create("http://mockbin.com/har"))
33
.header("accept", "application/json")
44
.header("x-foo", "Bar")
5+
.header("x-bar", "Foo")
56
.method("GET", HttpRequest.BodyPublishers.noBody())
67
.build();
78
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());

src/targets/java/okhttp/fixtures/headers.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
.get()
66
.addHeader("accept", "application/json")
77
.addHeader("x-foo", "Bar")
8+
.addHeader("x-bar", "Foo")
89
.build();
910

1011
Response response = client.newCall(request).execute();

0 commit comments

Comments
 (0)