Skip to content

Commit

Permalink
Fix HTTP header's casing
Browse files Browse the repository at this point in the history
Currently all HTTP request headers are in snake case and upper case.
The adopted standard is kebab case and title case.

Here you will find more details:
https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Standard_request_fields
  • Loading branch information
tatodorov committed Apr 20, 2024
1 parent 9efcf0b commit f2afa33
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/engines/bing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ impl SearchEngine for Bing {
}

let header_map = HeaderMap::try_from(&HashMap::from([
("USER_AGENT".to_string(), user_agent.to_string()),
("REFERER".to_string(), "https://google.com/".to_string()),
("User-Agent".to_string(), user_agent.to_string()),
("Referer".to_string(), "https://google.com/".to_string()),
(
"CONTENT_TYPE".to_string(),
"Content-Type".to_string(),
"application/x-www-form-urlencoded".to_string(),
),
("COOKIE".to_string(), cookie_string),
("Cookie".to_string(), cookie_string),
]))
.change_context(EngineError::UnexpectedError)?;

Expand Down
8 changes: 4 additions & 4 deletions src/engines/brave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ impl SearchEngine for Brave {
};

let header_map = HeaderMap::try_from(&HashMap::from([
("USER_AGENT".to_string(), user_agent.to_string()),
("User-Agent".to_string(), user_agent.to_string()),
(
"CONTENT_TYPE".to_string(),
"Content-Type".to_string(),
"application/x-www-form-urlencoded".to_string(),
),
("REFERER".to_string(), "https://google.com/".to_string()),
("Referer".to_string(), "https://google.com/".to_string()),
(
"COOKIE".to_string(),
"Cookie".to_string(),
format!("safe_search={safe_search_level}"),
),
]))
Expand Down
8 changes: 4 additions & 4 deletions src/engines/duckduckgo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ impl SearchEngine for DuckDuckGo {

// initializing HeaderMap and adding appropriate headers.
let header_map = HeaderMap::try_from(&HashMap::from([
("USER_AGENT".to_string(), user_agent.to_string()),
("REFERER".to_string(), "https://google.com/".to_string()),
("User-Agent".to_string(), user_agent.to_string()),
("Referer".to_string(), "https://google.com/".to_string()),
(
"CONTENT_TYPE".to_string(),
"Content-Type".to_string(),
"application/x-www-form-urlencoded".to_string(),
),
("COOKIE".to_string(), "kl=wt-wt".to_string()),
("Cookie".to_string(), "kl=wt-wt".to_string()),
]))
.change_context(EngineError::UnexpectedError)?;

Expand Down
8 changes: 4 additions & 4 deletions src/engines/librex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ impl SearchEngine for LibreX {

// initializing HeaderMap and adding appropriate headers.
let header_map = HeaderMap::try_from(&HashMap::from([
("USER_AGENT".to_string(), user_agent.to_string()),
("REFERER".to_string(), "https://google.com/".to_string()),
("CONTENT_TYPE".to_string(), "application/x-www-form-urlencoded".to_string()),
("User-Agent".to_string(), user_agent.to_string()),
("Referer".to_string(), "https://google.com/".to_string()),
("Content-Type".to_string(), "application/x-www-form-urlencoded".to_string()),
(
"COOKIE".to_string(),
"Cookie".to_string(),
"theme=amoled; disable_special=on; disable_frontends=on; language=en; number_of_results=10; safe_search=on; save=1".to_string(),
),
]))
Expand Down
8 changes: 4 additions & 4 deletions src/engines/mojeek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ impl SearchEngine for Mojeek {
}

let header_map = HeaderMap::try_from(&HashMap::from([
("USER_AGENT".to_string(), user_agent.to_string()),
("REFERER".to_string(), "https://google.com/".to_string()),
("User-Agent".to_string(), user_agent.to_string()),
("Referer".to_string(), "https://google.com/".to_string()),
(
"CONTENT_TYPE".to_string(),
"Content-Type".to_string(),
"application/x-www-form-urlencoded".to_string(),
),
("COOKIE".to_string(), cookie_string),
("Cookie".to_string(), cookie_string),
]))
.change_context(EngineError::UnexpectedError)?;

Expand Down
8 changes: 4 additions & 4 deletions src/engines/searx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ impl SearchEngine for Searx {

// initializing headers and adding appropriate headers.
let header_map = HeaderMap::try_from(&HashMap::from([
("USER_AGENT".to_string(), user_agent.to_string()),
("REFERER".to_string(), "https://google.com/".to_string()),
("CONTENT_TYPE".to_string(), "application/x-www-form-urlencoded".to_string()),
("COOKIE".to_string(), "categories=general; language=auto; locale=en; autocomplete=duckduckgo; image_proxy=1; method=POST; safesearch=2; theme=simple; results_on_new_tab=1; doi_resolver=oadoi.org; simple_style=auto; center_alignment=1; query_in_title=1; infinite_scroll=0; disabled_engines=; enabled_engines=\"archive is__general\\054yep__general\\054curlie__general\\054currency__general\\054ddg definitions__general\\054wikidata__general\\054duckduckgo__general\\054tineye__general\\054lingva__general\\054startpage__general\\054yahoo__general\\054wiby__general\\054marginalia__general\\054alexandria__general\\054wikibooks__general\\054wikiquote__general\\054wikisource__general\\054wikiversity__general\\054wikivoyage__general\\054dictzone__general\\054seznam__general\\054mojeek__general\\054naver__general\\054wikimini__general\\054brave__general\\054petalsearch__general\\054goo__general\"; disabled_plugins=; enabled_plugins=\"searx.plugins.hostname_replace\\054searx.plugins.oa_doi_rewrite\\054searx.plugins.vim_hotkeys\"; tokens=; maintab=on; enginetab=on".to_string())
("User-Agent".to_string(), user_agent.to_string()),
("Referer".to_string(), "https://google.com/".to_string()),
("Content-Type".to_string(), "application/x-www-form-urlencoded".to_string()),
("Cookie".to_string(), "categories=general; language=auto; locale=en; autocomplete=duckduckgo; image_proxy=1; method=POST; safesearch=2; theme=simple; results_on_new_tab=1; doi_resolver=oadoi.org; simple_style=auto; center_alignment=1; query_in_title=1; infinite_scroll=0; disabled_engines=; enabled_engines=\"archive is__general\\054yep__general\\054curlie__general\\054currency__general\\054ddg definitions__general\\054wikidata__general\\054duckduckgo__general\\054tineye__general\\054lingva__general\\054startpage__general\\054yahoo__general\\054wiby__general\\054marginalia__general\\054alexandria__general\\054wikibooks__general\\054wikiquote__general\\054wikisource__general\\054wikiversity__general\\054wikivoyage__general\\054dictzone__general\\054seznam__general\\054mojeek__general\\054naver__general\\054wikimini__general\\054brave__general\\054petalsearch__general\\054goo__general\"; disabled_plugins=; enabled_plugins=\"searx.plugins.hostname_replace\\054searx.plugins.oa_doi_rewrite\\054searx.plugins.vim_hotkeys\"; tokens=; maintab=on; enginetab=on".to_string())
]))
.change_context(EngineError::UnexpectedError)?;

Expand Down
8 changes: 4 additions & 4 deletions src/engines/startpage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ impl SearchEngine for Startpage {

// initializing HeaderMap and adding appropriate headers.
let header_map = HeaderMap::try_from(&HashMap::from([
("USER_AGENT".to_string(), user_agent.to_string()),
("REFERER".to_string(), "https://google.com/".to_string()),
("User-Agent".to_string(), user_agent.to_string()),
("Referer".to_string(), "https://google.com/".to_string()),
(
"CONTENT_TYPE".to_string(),
"Content-Type".to_string(),
"application/x-www-form-urlencoded".to_string(),
),
("COOKIE".to_string(), "preferences=connect_to_serverEEE0N1Ndate_timeEEEworldN1Ndisable_family_filterEEE0N1Ndisable_open_in_new_windowEEE0N1Nenable_post_methodEEE1N1Nenable_proxy_safety_suggestEEE1N1Nenable_stay_controlEEE0N1Ninstant_answersEEE1N1Nlang_homepageEEEs%2Fnight%2FenN1NlanguageEEEenglishN1Nlanguage_uiEEEenglishN1Nnum_of_resultsEEE10N1Nsearch_results_regionEEEallN1NsuggestionsEEE1N1Nwt_unitEEEcelsius".to_string()),
("Cookie".to_string(), "preferences=connect_to_serverEEE0N1Ndate_timeEEEworldN1Ndisable_family_filterEEE0N1Ndisable_open_in_new_windowEEE0N1Nenable_post_methodEEE1N1Nenable_proxy_safety_suggestEEE1N1Nenable_stay_controlEEE0N1Ninstant_answersEEE1N1Nlang_homepageEEEs%2Fnight%2FenN1NlanguageEEEenglishN1Nlanguage_uiEEEenglishN1Nnum_of_resultsEEE10N1Nsearch_results_regionEEEallN1NsuggestionsEEE1N1Nwt_unitEEEcelsius".to_string()),
]))
.change_context(EngineError::UnexpectedError)?;

Expand Down

0 comments on commit f2afa33

Please sign in to comment.