Skip to content

Commit 0b06ca8

Browse files
committed
Add user-agent header to outgoing http requests
The tests are also updated to ensure that the user-agent is set for outgoing requests to GitHub and S3.
1 parent b00e945 commit 0b06ca8

40 files changed

+7
-301
lines changed

src/github.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ where
2424
.get(&url)
2525
.header(header::ACCEPT, "application/vnd.github.v3+json")
2626
.header(header::AUTHORIZATION, format!("token {}", auth.secret()))
27+
.header(header::USER_AGENT, "https://crates.io")
2728
.send()?
2829
.error_for_status()
2930
.map_err(|e| handle_error_response(&e))?

src/s3/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ impl Bucket {
6363
.header(header::AUTHORIZATION, auth)
6464
.header(header::CONTENT_TYPE, content_type)
6565
.header(header::DATE, date)
66+
.header(header::USER_AGENT, "https://crates.io")
6667
.headers(extra_headers)
6768
.body(Body::sized(content, content_length))
6869
.send()?

src/tests/http-data/krate_good_badges

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
"authorization",
2121
"AWS AKIAICL5IWUZYWWKA7JA:kDm23yhf8YuOKpTcbHhNBa6BtQw="
2222
],
23-
[
24-
"user-agent",
25-
"reqwest/0.9.1"
26-
],
2723
[
2824
"host",
2925
"alexcrichton-test.s3.amazonaws.com"

src/tests/http-data/krate_good_categories

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
"date",
2929
"Fri, 15 Sep 2017 07:53:05 -0700"
3030
],
31-
[
32-
"user-agent",
33-
"reqwest/0.9.1"
34-
],
3531
[
3632
"accept",
3733
"*/*"

src/tests/http-data/krate_ignored_badges

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
"content-length",
2121
"35"
2222
],
23-
[
24-
"user-agent",
25-
"reqwest/0.9.1"
26-
],
2723
[
2824
"accept-encoding",
2925
"gzip"

src/tests/http-data/krate_ignored_categories

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
"content-length",
99
"35"
1010
],
11-
[
12-
"user-agent",
13-
"reqwest/0.9.1"
14-
],
1511
[
1612
"authorization",
1713
"AWS AKIAICL5IWUZYWWKA7JA:V37kbEzeh57sB4yTSZIOJACPoP4="

src/tests/http-data/krate_new_krate

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
"accept-encoding",
2121
"gzip"
2222
],
23-
[
24-
"user-agent",
25-
"reqwest/0.9.1"
26-
],
2723
[
2824
"content-type",
2925
"application/x-tar"

src/tests/http-data/krate_new_krate_git_upload

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
[
3232
"accept",
3333
"*/*"
34-
],
35-
[
36-
"user-agent",
37-
"reqwest/0.9.1"
3834
]
3935
],
4036
"body": "H4sIAAAAAAAA/+3AAQEAAACCIP+vbkhQwKsBLq+17wAEAAA="

src/tests/http-data/krate_new_krate_git_upload_appends

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
"accept",
2121
"*/*"
2222
],
23-
[
24-
"user-agent",
25-
"reqwest/0.9.1"
26-
],
2723
[
2824
"authorization",
2925
"AWS AKIAICL5IWUZYWWKA7JA:UgUqqHJ9cQAZDdbcsxpnC0BI2eE="
@@ -91,10 +87,6 @@
9187
"accept",
9288
"*/*"
9389
],
94-
[
95-
"user-agent",
96-
"reqwest/0.9.1"
97-
],
9890
[
9991
"authorization",
10092
"AWS AKIAICL5IWUZYWWKA7JA:UgUqqHJ9cQAZDdbcsxpnC0BI2eE="

src/tests/http-data/krate_new_krate_git_upload_with_conflicts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
"authorization",
2525
"AWS AKIAICL5IWUZYWWKA7JA:241ftMxnamoj94RBOB/al86Xwjk="
2626
],
27-
[
28-
"user-agent",
29-
"reqwest/0.9.1"
30-
],
3127
[
3228
"accept",
3329
"*/*"

0 commit comments

Comments
 (0)