From 8403238dbbddedcd3d89f51c18f0212773122a27 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Fri, 16 Sep 2022 02:18:28 +0100 Subject: [PATCH] Use Accept header instead of Content-Type header for client content negotiation --- src/cli/sql.rs | 4 ++-- src/net/import.rs | 2 +- src/net/key.rs | 16 ++++++++-------- src/net/sql.rs | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cli/sql.rs b/src/cli/sql.rs index 205d7d38..a93bff88 100644 --- a/src/cli/sql.rs +++ b/src/cli/sql.rs @@ -1,7 +1,7 @@ use crate::err::Error; use reqwest::blocking::Client; use reqwest::blocking::Response; -use reqwest::header::CONTENT_TYPE; +use reqwest::header::ACCEPT; use rustyline::error::ReadlineError; use rustyline::Editor; use serde_json::Value; @@ -41,7 +41,7 @@ pub fn init(matches: &clap::ArgMatches) -> Result<(), Error> { // Make a new remote request let res = Client::new() .post(&conn) - .header(CONTENT_TYPE, "application/json") + .header(ACCEPT, "application/json") .basic_auth(user, Some(pass)); // Add NS header if specified let res = match ns { diff --git a/src/net/import.rs b/src/net/import.rs index 40221323..983f56d7 100644 --- a/src/net/import.rs +++ b/src/net/import.rs @@ -15,7 +15,7 @@ pub fn config() -> impl Filter(http::header::CONTENT_TYPE.as_str())) + .and(warp::header::(http::header::ACCEPT.as_str())) .and(warp::body::content_length_limit(MAX)) .and(warp::body::bytes()) .and_then(handler) diff --git a/src/net/key.rs b/src/net/key.rs index ce644336..5674be26 100644 --- a/src/net/key.rs +++ b/src/net/key.rs @@ -36,7 +36,7 @@ pub fn config() -> impl Filter(http::header::CONTENT_TYPE.as_str())) + .and(warp::header::(http::header::ACCEPT.as_str())) .and(path!("key" / String).and(warp::path::end())) .and(warp::query()) .and_then(select_all); @@ -44,7 +44,7 @@ pub fn config() -> impl Filter(http::header::CONTENT_TYPE.as_str())) + .and(warp::header::(http::header::ACCEPT.as_str())) .and(path!("key" / String).and(warp::path::end())) .and(warp::body::content_length_limit(MAX)) .and(warp::body::bytes()) @@ -53,7 +53,7 @@ pub fn config() -> impl Filter(http::header::CONTENT_TYPE.as_str())) + .and(warp::header::(http::header::ACCEPT.as_str())) .and(path!("key" / String).and(warp::path::end())) .and_then(delete_all); // Specify route @@ -67,14 +67,14 @@ pub fn config() -> impl Filter(http::header::CONTENT_TYPE.as_str())) + .and(warp::header::(http::header::ACCEPT.as_str())) .and(path!("key" / String / String).and(warp::path::end())) .and_then(select_one); // Set create method let create = warp::any() .and(warp::post()) .and(session::build()) - .and(warp::header::(http::header::CONTENT_TYPE.as_str())) + .and(warp::header::(http::header::ACCEPT.as_str())) .and(path!("key" / String / String).and(warp::path::end())) .and(warp::body::content_length_limit(MAX)) .and(warp::body::bytes()) @@ -83,7 +83,7 @@ pub fn config() -> impl Filter(http::header::CONTENT_TYPE.as_str())) + .and(warp::header::(http::header::ACCEPT.as_str())) .and(path!("key" / String / String).and(warp::path::end())) .and(warp::body::content_length_limit(MAX)) .and(warp::body::bytes()) @@ -92,7 +92,7 @@ pub fn config() -> impl Filter(http::header::CONTENT_TYPE.as_str())) + .and(warp::header::(http::header::ACCEPT.as_str())) .and(path!("key" / String / String).and(warp::path::end())) .and(warp::body::content_length_limit(MAX)) .and(warp::body::bytes()) @@ -101,7 +101,7 @@ pub fn config() -> impl Filter(http::header::CONTENT_TYPE.as_str())) + .and(warp::header::(http::header::ACCEPT.as_str())) .and(path!("key" / String / String).and(warp::path::end())) .and_then(delete_one); // Specify route diff --git a/src/net/sql.rs b/src/net/sql.rs index c52737ca..7f31b035 100644 --- a/src/net/sql.rs +++ b/src/net/sql.rs @@ -20,7 +20,7 @@ pub fn config() -> impl Filter(http::header::CONTENT_TYPE.as_str())) + .and(warp::header::(http::header::ACCEPT.as_str())) .and(warp::body::content_length_limit(MAX)) .and(warp::body::bytes()) .and_then(handler);