-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Send Content-Type header with cargo publish requests #16832
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -244,7 +244,7 @@ impl Registry { | |
|
|
||
| pub fn add_owners(&mut self, krate: &str, owners: &[&str]) -> Result<String> { | ||
| let body = serde_json::to_string(&OwnersReq { users: owners })?; | ||
| let body = self.put(&format!("/crates/{}/owners", krate), body.as_bytes())?; | ||
| let body = self.put(&format!("/crates/{}/owners", krate), Some(body.as_bytes()))?; | ||
| assert!(serde_json::from_str::<OwnerResponse>(&body)?.ok); | ||
| Ok(serde_json::from_str::<OwnerResponse>(&body)?.msg) | ||
| } | ||
|
|
@@ -293,6 +293,7 @@ impl Registry { | |
| self.handle.url(&url)?; | ||
| self.handle.in_filesize(size as u64)?; | ||
| let mut headers = List::new(); | ||
| headers.append("Content-Type: application/octet-stream")?; | ||
| headers.append("Accept: application/json")?; | ||
| headers.append(&format!("Authorization: {}", self.token()?))?; | ||
| self.handle.http_headers(headers)?; | ||
|
|
@@ -364,14 +365,14 @@ impl Registry { | |
| } | ||
|
|
||
| pub fn unyank(&mut self, krate: &str, version: &str) -> Result<()> { | ||
| let body = self.put(&format!("/crates/{}/{}/unyank", krate, version), &[])?; | ||
| let body = self.put(&format!("/crates/{}/{}/unyank", krate, version), None)?; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was setting |
||
| assert!(serde_json::from_str::<R>(&body)?.ok); | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn put(&mut self, path: &str, b: &[u8]) -> Result<String> { | ||
| fn put(&mut self, path: &str, b: Option<&[u8]>) -> Result<String> { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is how all of the other methods were written, this was otherwise an outlier. |
||
| self.handle.put(true)?; | ||
| self.req(path, Some(b), Auth::Authorized) | ||
| self.req(path, b, Auth::Authorized) | ||
| } | ||
|
|
||
| fn get(&mut self, path: &str) -> Result<String> { | ||
|
|
||
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.
#16830 (comment)
Would you mind also updating docs?
I guess we can instead specify content-type in each API respectively