Skip to content
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

Replace http-types with http #2233

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
232 changes: 39 additions & 193 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fe2o3-amqp-types = { version = "0.12" }
futures = "0.3"
getrandom = { version = "0.2", features = ["js"] }
hmac = { version = "0.12" }
http-types = { version = "2.12", default-features = false }
http = { version = "1.2", default-features = false }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on all the build errors, we need at least std.

log = "0.4"
oauth2 = { version = "5.0.0", default-features = false }
once_cell = "1.18"
Expand Down
2 changes: 1 addition & 1 deletion eng/dict/crates.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dyn-clone
futures
getrandom
hmac
http-types
http
oauth2
once_cell
openssl
Expand Down
2 changes: 1 addition & 1 deletion eng/test/mock_transport/src/mock_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl Serialize for MockResponse {
for (h, v) in self.headers.iter() {
headers.insert(h.as_str().into(), v.as_str().into());
}
let status = self.status as u16;
let status = u16::from(self.status);
let body = base64::encode(&self.body);
let s = SerializedMockResponse {
status,
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure_core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
match client.get_secret("secret-name", "", None).await {
Ok(secret) => println!("Secret: {:?}", secret.into_body().await?.value),
Err(e) => match e.kind() {
ErrorKind::HttpResponse { status, error_code, .. } if *status == StatusCode::NotFound => {
ErrorKind::HttpResponse { status, error_code, .. } if *status == StatusCode::NOT_FOUND => {
// handle not found error
if let Some(code) = error_code {
println!("ErrorCode: {}", code);
Expand Down
8 changes: 4 additions & 4 deletions sdk/core/azure_core/src/lro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ pub mod body_content {
S: Serialize,
{
match status_code {
StatusCode::Accepted => Ok(LroStatus::InProgress),
StatusCode::Created => {
StatusCode::ACCEPTED => Ok(LroStatus::InProgress),
StatusCode::CREATED => {
Ok(get_provisioning_state_from_body(body).unwrap_or(LroStatus::InProgress))
}
StatusCode::Ok => {
StatusCode::OK => {
Ok(get_provisioning_state_from_body(body).unwrap_or(LroStatus::Succeeded))
}
StatusCode::NoContent => Ok(LroStatus::Succeeded),
StatusCode::NO_CONTENT => Ok(LroStatus::Succeeded),
_ => Err(crate::error::Error::from(
crate::error::ErrorKind::HttpResponse {
status: status_code,
Expand Down
16 changes: 8 additions & 8 deletions sdk/core/azure_core_test/src/proxy/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Client {
let ctx = Context::with_context(&options.method_options.context);
let mut url = self.endpoint.clone();
url = url.join("/Record/Start")?;
let mut request = Request::new(url, Method::Post);
let mut request = Request::new(url, Method::POST);
request.insert_header(ACCEPT, "application/json");
request.insert_header(CONTENT_TYPE, "application/json");
request.set_body(body);
Expand All @@ -79,7 +79,7 @@ impl Client {
let ctx = Context::with_context(&options.method_options.context);
let mut url = self.endpoint.clone();
url = url.join("/Record/Stop")?;
let mut request = Request::new(url, Method::Post);
let mut request = Request::new(url, Method::POST);
request.insert_header(ACCEPT, "application/json");
request.insert_header(CONTENT_TYPE, "application/json");
request.insert_header(RECORDING_ID, recording_id.to_string());
Expand All @@ -102,7 +102,7 @@ impl Client {
let ctx = Context::with_context(&options.method_options.context);
let mut url = self.endpoint.clone();
url = url.join("/Playback/Start")?;
let mut request = Request::new(url, Method::Post);
let mut request = Request::new(url, Method::POST);
request.insert_header(ACCEPT, "application/json");
request.insert_header(CONTENT_TYPE, "application/json");
request.add_optional_header(&options.recording_id);
Expand All @@ -127,7 +127,7 @@ impl Client {
let ctx = Context::with_context(&options.method_options.context);
let mut url = self.endpoint.clone();
url = url.join("/Playback/Stop")?;
let mut request = Request::new(url, Method::Post);
let mut request = Request::new(url, Method::POST);
request.insert_header(ACCEPT, "application/json");
request.insert_header(CONTENT_TYPE, "application/json");
request.insert_header(RECORDING_ID, recording_id.to_string());
Expand All @@ -149,7 +149,7 @@ impl Client {
let ctx = Context::with_context(&options.method_options.context);
let mut url = self.endpoint.clone();
url = url.join("/Admin/SetMatcher")?;
let mut request = Request::new(url, Method::Post);
let mut request = Request::new(url, Method::POST);
request.insert_header(ACCEPT, "application/json");
request.insert_header(CONTENT_TYPE, "application/json");
request.insert_headers(&matcher)?;
Expand All @@ -176,7 +176,7 @@ impl Client {
let ctx = Context::with_context(&options.method_options.context);
let mut url = self.endpoint.clone();
url = url.join("/Admin/AddSanitizer")?;
let mut request = Request::new(url, Method::Post);
let mut request = Request::new(url, Method::POST);
request.insert_header(ACCEPT, "application/json");
request.insert_header(CONTENT_TYPE, "application/json");
request.insert_headers(&sanitizer)?;
Expand All @@ -199,7 +199,7 @@ impl Client {
let ctx = Context::with_context(&options.method_options.context);
let mut url = self.endpoint.clone();
url = url.join("/Admin/RemoveSanitizers")?;
let mut request = Request::new(url, Method::Post);
let mut request = Request::new(url, Method::POST);
request.insert_header(ACCEPT, "application/json");
request.insert_header(CONTENT_TYPE, "application/json");
request.add_optional_header(&options.recording_id);
Expand All @@ -221,7 +221,7 @@ impl Client {
let ctx = Context::with_context(&options.method_options.context);
let mut url = self.endpoint.clone();
url = url.join("/Admin/Reset")?;
let mut request = Request::new(url, Method::Post);
let mut request = Request::new(url, Method::POST);
request.insert_header(ACCEPT, "application/json");
request.insert_header(CONTENT_TYPE, "application/json");
request.add_optional_header(&options.recording_id);
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure_core_test/src/proxy/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct Error {

impl Error {
fn default_status() -> StatusCode {
StatusCode::Ok
StatusCode::OK
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure_data_cosmos/examples/cosmos/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl DeleteCommand {
.delete_item(partition_key, &item_id, None)
.await;
match response {
Err(e) if e.http_status() == Some(StatusCode::NotFound) => {
Err(e) if e.http_status() == Some(StatusCode::NOT_FOUND) => {
println!("Item not found!")
}
Ok(_) => println!("Item deleted"),
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure_data_cosmos/examples/cosmos/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl PatchCommand {
.patch_item(pk, &self.item_id, patch, None)
.await;
match response {
Err(e) if e.http_status() == Some(StatusCode::NotFound) => println!("Item not found!"),
Err(e) if e.http_status() == Some(StatusCode::NOT_FOUND) => println!("Item not found!"),
Ok(r) => {
let item: serde_json::Value = r.into_json_body().await?;
println!("Patched item:");
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure_data_cosmos/examples/cosmos/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl ReadCommand {
.read_item(&partition_key, &item_id, None)
.await;
match response {
Err(e) if e.http_status() == Some(StatusCode::NotFound) => {
Err(e) if e.http_status() == Some(StatusCode::NOT_FOUND) => {
println!("Item not found!")
}
Ok(r) => {
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure_data_cosmos/examples/cosmos/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl ReplaceCommand {
.replace_item(pk, &item_id, item, Some(options))
.await;
match response {
Err(e) if e.http_status() == Some(StatusCode::NotFound) => {
Err(e) if e.http_status() == Some(StatusCode::NOT_FOUND) => {
println!("Item not found!")
}
Ok(r) => {
Expand Down
20 changes: 10 additions & 10 deletions sdk/cosmos/azure_data_cosmos/src/clients/container_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl ContainerClient {
) -> azure_core::Result<Response<ContainerProperties>> {
let options = options.unwrap_or_default();
let url = self.pipeline.url(&self.link);
let mut req = Request::new(url, Method::Get);
let mut req = Request::new(url, Method::GET);
self.pipeline
.send(options.method_options.context, &mut req, self.link.clone())
.await
Expand Down Expand Up @@ -108,7 +108,7 @@ impl ContainerClient {
) -> azure_core::Result<Response<ContainerProperties>> {
let options = options.unwrap_or_default();
let url = self.pipeline.url(&self.link);
let mut req = Request::new(url, Method::Put);
let mut req = Request::new(url, Method::PUT);
req.set_json(&properties)?;
self.pipeline
.send(options.method_options.context, &mut req, self.link.clone())
Expand Down Expand Up @@ -175,7 +175,7 @@ impl ContainerClient {
) -> azure_core::Result<Response> {
let options = options.unwrap_or_default();
let url = self.pipeline.url(&self.link);
let mut req = Request::new(url, Method::Delete);
let mut req = Request::new(url, Method::DELETE);
self.pipeline
.send(options.method_options.context, &mut req, self.link.clone())
.await
Expand Down Expand Up @@ -255,7 +255,7 @@ impl ContainerClient {
) -> azure_core::Result<Response> {
let options = options.unwrap_or_default();
let url = self.pipeline.url(&self.items_link);
let mut req = Request::new(url, Method::Post);
let mut req = Request::new(url, Method::POST);
if !options.enable_content_response_on_write {
req.insert_header(azure_core::headers::PREFER, constants::PREFER_MINIMAL);
}
Expand Down Expand Up @@ -346,7 +346,7 @@ impl ContainerClient {
let options = options.unwrap_or_default();
let link = self.items_link.item(item_id);
let url = self.pipeline.url(&link);
let mut req = Request::new(url, Method::Put);
let mut req = Request::new(url, Method::PUT);
if !options.enable_content_response_on_write {
req.insert_header(azure_core::headers::PREFER, constants::PREFER_MINIMAL);
}
Expand Down Expand Up @@ -434,7 +434,7 @@ impl ContainerClient {
) -> azure_core::Result<Response> {
let options = options.unwrap_or_default();
let url = self.pipeline.url(&self.items_link);
let mut req = Request::new(url, Method::Post);
let mut req = Request::new(url, Method::POST);
if !options.enable_content_response_on_write {
req.insert_header(azure_core::headers::PREFER, constants::PREFER_MINIMAL);
}
Expand Down Expand Up @@ -492,7 +492,7 @@ impl ContainerClient {
let options = options.unwrap_or_default();
let link = self.items_link.item(item_id);
let url = self.pipeline.url(&link);
let mut req = Request::new(url, Method::Get);
let mut req = Request::new(url, Method::GET);
req.insert_headers(&partition_key.into())?;
self.pipeline
.send(options.method_options.context, &mut req, link)
Expand Down Expand Up @@ -528,7 +528,7 @@ impl ContainerClient {
let options = options.unwrap_or_default();
let link = self.items_link.item(item_id);
let url = self.pipeline.url(&link);
let mut req = Request::new(url, Method::Delete);
let mut req = Request::new(url, Method::DELETE);
req.insert_headers(&partition_key.into())?;
self.pipeline
.send(options.method_options.context, &mut req, link)
Expand Down Expand Up @@ -601,7 +601,7 @@ impl ContainerClient {
let options = options.unwrap_or_default();
let link = self.items_link.item(item_id);
let url = self.pipeline.url(&link);
let mut req = Request::new(url, Method::Patch);
let mut req = Request::new(url, Method::PATCH);
if !options.enable_content_response_on_write {
req.insert_header(azure_core::headers::PREFER, constants::PREFER_MINIMAL);
}
Expand Down Expand Up @@ -674,7 +674,7 @@ impl ContainerClient {
) -> azure_core::Result<Pager<QueryResults<T>>> {
let options = options.unwrap_or_default();
let url = self.pipeline.url(&self.items_link);
let mut base_request = Request::new(url, Method::Post);
let mut base_request = Request::new(url, Method::POST);
let QueryPartitionStrategy::SinglePartition(partition_key) = partition_key.into();
base_request.insert_headers(&partition_key)?;

Expand Down
4 changes: 2 additions & 2 deletions sdk/cosmos/azure_data_cosmos/src/clients/cosmos_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl CosmosClient {
) -> azure_core::Result<azure_core::Pager<DatabaseQueryResults>> {
let options = options.unwrap_or_default();
let url = self.pipeline.url(&self.databases_link);
let base_request = Request::new(url, azure_core::Method::Post);
let base_request = Request::new(url, azure_core::Method::POST);

self.pipeline.send_query_request(
options.method_options.context,
Expand Down Expand Up @@ -162,7 +162,7 @@ impl CosmosClient {
}

let url = self.pipeline.url(&self.databases_link);
let mut req = Request::new(url, Method::Post);
let mut req = Request::new(url, Method::POST);
req.insert_headers(&options.throughput)?;
req.set_json(&RequestBody { id })?;

Expand Down
8 changes: 4 additions & 4 deletions sdk/cosmos/azure_data_cosmos/src/clients/database_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl DatabaseClient {
) -> azure_core::Result<Response<DatabaseProperties>> {
let options = options.unwrap_or_default();
let url = self.pipeline.url(&self.link);
let mut req = Request::new(url, Method::Get);
let mut req = Request::new(url, Method::GET);
self.pipeline
.send(options.method_options.context, &mut req, self.link.clone())
.await
Expand Down Expand Up @@ -112,7 +112,7 @@ impl DatabaseClient {
) -> azure_core::Result<Pager<ContainerQueryResults>> {
let options = options.unwrap_or_default();
let url = self.pipeline.url(&self.containers_link);
let base_request = Request::new(url, Method::Post);
let base_request = Request::new(url, Method::POST);

self.pipeline.send_query_request(
options.method_options.context,
Expand All @@ -136,7 +136,7 @@ impl DatabaseClient {
) -> azure_core::Result<Response<ContainerProperties>> {
let options = options.unwrap_or_default();
let url = self.pipeline.url(&self.containers_link);
let mut req = Request::new(url, Method::Post);
let mut req = Request::new(url, Method::POST);
req.insert_headers(&options.throughput)?;
req.set_json(&properties)?;

Expand All @@ -161,7 +161,7 @@ impl DatabaseClient {
) -> azure_core::Result<Response> {
let options = options.unwrap_or_default();
let url = self.pipeline.url(&self.link);
let mut req = Request::new(url, Method::Delete);
let mut req = Request::new(url, Method::DELETE);
self.pipeline
.send(options.method_options.context, &mut req, self.link.clone())
.await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Policy for AuthorizationPolicy {
let auth = generate_authorization(
&self.credential,
request.url(),
SignatureTarget::new(*request.method(), resource_link, &date_string),
SignatureTarget::new(request.method().clone(), resource_link, &date_string),
)
.await?;

Expand Down Expand Up @@ -190,7 +190,7 @@ mod tests {
&auth_token,
&url,
SignatureTarget::new(
azure_core::Method::Get,
azure_core::Method::GET,
&ResourceLink::root(ResourceType::Databases).item("ToDoList"),
&date_string,
),
Expand Down Expand Up @@ -222,7 +222,7 @@ mod tests {
&auth_token,
&url,
SignatureTarget::new(
azure_core::Method::Get,
azure_core::Method::GET,
&ResourceLink::root(ResourceType::Databases)
.item("MyDatabase")
.feed(ResourceType::Containers)
Expand Down Expand Up @@ -256,7 +256,7 @@ mod tests {
&auth_token,
&url,
SignatureTarget::new(
azure_core::Method::Get,
azure_core::Method::GET,
&ResourceLink::root(ResourceType::Databases).item("ToDoList"),
&date_string,
),
Expand Down
6 changes: 3 additions & 3 deletions sdk/cosmos/azure_data_cosmos/src/pipeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl CosmosPipeline {
let mut results: Pager<OfferResults> = self.send_query_request(
context.clone(),
query,
Request::new(self.url(&offers_link), Method::Post),
Request::new(self.url(&offers_link), Method::POST),
offers_link.clone(),
)?;
let offers = results
Expand All @@ -149,7 +149,7 @@ impl CosmosPipeline {
let offer_url = self.url(&offer_link);

// Now we can read the offer itself
let mut req = Request::new(offer_url, Method::Get);
let mut req = Request::new(offer_url, Method::GET);
self.send(context, &mut req, offer_link).await.map(Some)
}

Expand Down Expand Up @@ -177,7 +177,7 @@ impl CosmosPipeline {
// NOTE: Offers API doesn't allow Enable Content Response On Write to be false, so once we support that option, we'll need to ignore it here.
let offer_link =
ResourceLink::root(ResourceType::Offers).item(&current_throughput.offer_id);
let mut req = Request::new(self.url(&offer_link), Method::Put);
let mut req = Request::new(self.url(&offer_link), Method::PUT);
req.set_json(&current_throughput)?;

self.send(context, &mut req, offer_link).await
Expand Down
Loading
Loading