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
"*/*"

src/tests/http-data/krate_new_krate_records_verified_email

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_too_big_but_whitelisted

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
[
3232
"date",
3333
"Fri, 15 Sep 2017 07:53:06 -0700"
34-
],
35-
[
36-
"user-agent",
37-
"reqwest/0.9.1"
3834
]
3935
],
4036
"body": "H4sIAAAAAAAA/+3GTQqAIBAG0DmKF8jUoDlOGPQzEAg50fVDon0rIfre6s0pDecqOm2StfHWW9eOslAN7tZxcM+Lcu4DUxVH1rgbQz8VAQAA4PMIAOClC25Yv/oADgAA"

src/tests/http-data/krate_new_krate_twice

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:06 -0700"
3030
],
31-
[
32-
"user-agent",
33-
"reqwest/0.9.1"
34-
],
3531
[
3632
"host",
3733
"alexcrichton-test.s3.amazonaws.com"

src/tests/http-data/krate_new_krate_weird_version

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212
"accept-encoding",
1313
"gzip"
1414
],
15-
[
16-
"user-agent",
17-
"reqwest/0.9.1"
18-
],
1915
[
2016
"authorization",
2117
"AWS AKIAICL5IWUZYWWKA7JA:eW1SP7V3WdqHXWZLcbN1BI2Zo0g="

src/tests/http-data/krate_new_krate_with_dependency

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
"content-length",
2929
"35"
3030
],
31-
[
32-
"user-agent",
33-
"reqwest/0.9.1"
34-
],
3531
[
3632
"accept",
3733
"*/*"

src/tests/http-data/krate_new_krate_with_readme

Lines changed: 0 additions & 8 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"
@@ -99,10 +95,6 @@
9995
"host",
10096
"alexcrichton-test.s3.amazonaws.com"
10197
],
102-
[
103-
"user-agent",
104-
"reqwest/0.9.1"
105-
],
10698
[
10799
"content-length",
108100
"0"

src/tests/http-data/krate_new_krate_with_token

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
"date",
99
"Fri, 15 Sep 2017 07:53:06 -0700"
1010
],
11-
[
12-
"user-agent",
13-
"reqwest/0.9.1"
14-
],
1511
[
1612
"authorization",
1713
"AWS AKIAICL5IWUZYWWKA7JA:uDc39eNdF6CcwB+q+JwKsoDLQc4="

src/tests/http-data/krate_new_with_renamed_dependency

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
"uri": "http://alexcrichton-test.s3.amazonaws.com/crates/new-krate/new-krate-1.0.0.crate",
55
"method": "PUT",
66
"headers": [
7-
[
8-
"user-agent",
9-
"reqwest/0.9.1"
10-
],
117
[
128
"accept",
139
"*/*"

src/tests/http-data/krate_publish_after_removing_documentation

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
"host",
2525
"alexcrichton-test.s3.amazonaws.com"
2626
],
27-
[
28-
"user-agent",
29-
"reqwest/0.9.1"
30-
],
3127
[
3228
"date",
3329
"Fri, 15 Sep 2017 07:53:06 -0700"
@@ -99,10 +95,6 @@
9995
"accept-encoding",
10096
"gzip"
10197
],
102-
[
103-
"user-agent",
104-
"reqwest/0.9.1"
105-
],
10698
[
10799
"accept",
108100
"*/*"

src/tests/http-data/krate_publish_after_yank_max_version

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
"host",
99
"alexcrichton-test.s3.amazonaws.com"
1010
],
11-
[
12-
"user-agent",
13-
"reqwest/0.9.1"
14-
],
1511
[
1612
"content-type",
1713
"application/x-tar"
@@ -83,10 +79,6 @@
8379
"authorization",
8480
"AWS AKIAICL5IWUZYWWKA7JA:umuWs3XoGqsDipgMq04QAhq9Spc="
8581
],
86-
[
87-
"user-agent",
88-
"reqwest/0.9.1"
89-
],
9082
[
9183
"date",
9284
"Fri, 15 Sep 2017 07:53:06 -0700"

src/tests/http-data/krate_publish_new_crate_rate_limited

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
"date",
2929
"Fri, 15 Sep 2017 07:53:06 -0700"
3030
],
31-
[
32-
"user-agent",
33-
"reqwest/0.9.1"
34-
],
3531
[
3632
"host",
3733
"alexcrichton-test.s3.amazonaws.com"
@@ -99,10 +95,6 @@
9995
"date",
10096
"Fri, 15 Sep 2017 07:53:06 -0700"
10197
],
102-
[
103-
"user-agent",
104-
"reqwest/0.9.1"
105-
],
10698
[
10799
"host",
108100
"alexcrichton-test.s3.amazonaws.com"

src/tests/http-data/krate_publish_rate_limit_doesnt_affect_existing_crates

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
"date",
2929
"Fri, 15 Sep 2017 07:53:06 -0700"
3030
],
31-
[
32-
"user-agent",
33-
"reqwest/0.9.1"
34-
],
3531
[
3632
"host",
3733
"alexcrichton-test.s3.amazonaws.com"
@@ -99,10 +95,6 @@
9995
"date",
10096
"Fri, 15 Sep 2017 07:53:06 -0700"
10197
],
102-
[
103-
"user-agent",
104-
"reqwest/0.9.1"
105-
],
10698
[
10799
"host",
108100
"alexcrichton-test.s3.amazonaws.com"

src/tests/http-data/krate_publish_records_an_audit_action

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
"accept",
1717
"*/*"
1818
],
19-
[
20-
"user-agent",
21-
"reqwest/0.9.1"
22-
],
2319
[
2420
"authorization",
2521
"AWS AKIAICL5IWUZYWWKA7JA:xCp3sUdUdmScjI6ct58zFv6BoGQ="

src/tests/http-data/krate_unyank_records_an_audit_action

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
"accept",
1717
"*/*"
1818
],
19-
[
20-
"user-agent",
21-
"reqwest/0.9.1"
22-
],
2319
[
2420
"authorization",
2521
"AWS AKIAICL5IWUZYWWKA7JA:xCp3sUdUdmScjI6ct58zFv6BoGQ="

src/tests/http-data/krate_uploading_new_version_touches_crate

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
[
3232
"content-type",
3333
"application/x-tar"
34-
],
35-
[
36-
"user-agent",
37-
"reqwest/0.9.1"
3834
]
3935
],
4036
"body": "H4sIAAAAAAAA/+3AAQEAAACCIP+vbkhQwKsBLq+17wAEAAA="
@@ -91,10 +87,6 @@
9187
"accept-encoding",
9288
"gzip"
9389
],
94-
[
95-
"user-agent",
96-
"reqwest/0.9.1"
97-
],
9890
[
9991
"content-length",
10092
"35"

src/tests/http-data/krate_yank_max_version

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
"date",
2929
"Fri, 15 Sep 2017 07:53:06 -0700"
3030
],
31-
[
32-
"user-agent",
33-
"reqwest/0.9.1"
34-
],
3531
[
3632
"accept-encoding",
3733
"gzip"
@@ -83,10 +79,6 @@
8379
"accept-encoding",
8480
"gzip"
8581
],
86-
[
87-
"user-agent",
88-
"reqwest/0.9.1"
89-
],
9082
[
9183
"authorization",
9284
"AWS AKIAICL5IWUZYWWKA7JA:umuWs3XoGqsDipgMq04QAhq9Spc="

src/tests/http-data/krate_yank_records_an_audit_action

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
"accept",
1717
"*/*"
1818
],
19-
[
20-
"user-agent",
21-
"reqwest/0.9.1"
22-
],
2319
[
2420
"authorization",
2521
"AWS AKIAICL5IWUZYWWKA7JA:xCp3sUdUdmScjI6ct58zFv6BoGQ="

src/tests/http-data/krate_yank_works_as_intended

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
"accept",
1717
"*/*"
1818
],
19-
[
20-
"user-agent",
21-
"reqwest/0.9.1"
22-
],
2319
[
2420
"authorization",
2521
"AWS AKIAICL5IWUZYWWKA7JA:xCp3sUdUdmScjI6ct58zFv6BoGQ="

0 commit comments

Comments
 (0)