Header order is not maintained when headers or header_options are passed as options to GET method call

Open
#1 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
ruby, rust
Domain
networking

Research direction

Reproduce the five calls in the issue's script, starting at the Wreq::Client#get entry point, and trace how per-call options are combined with client options. Done means calls like tests 2 and 4 retain the requested header order while the existing client-only behavior remains unchanged.

Written by the indexing model from the issue text.

Description

Summary:

Header Orders are not maintained when headers or header_options are added to options in GET method call arguments.

Reproduction Script:

require 'wreq-rb'
require 'json'

url= "https://tls.peet.ws/api/all"

headers = {
  "a" => "1",
  "b" => "2",
  "c" => "3",
  "d" => "4",
}

header_order = [
  "a",
  "b",
  "c",
  "d",
]

options = {
  headers: headers,
  header_order: header_order,
  emulation: "edge_145",
}

puts "Test #1: set options on client Only"
client_1 = Wreq::Client.new(**options)
response_1 = client_1.get(url)
headers_1 = JSON.parse(response_1.text)["http2"]["sent_frames"][2]["headers"]
puts headers_1
puts "\n\n"

puts "Test #2: set options on client and get method"
client_2 = Wreq::Client.new(**options)
response_2 = client_2.get(url, **options)
headers_2 = JSON.parse(response_2.text)["http2"]["sent_frames"][2]["headers"]
puts headers_2
puts "\n\n"

puts "Test #3: set options on client and get method except header_order"
client_3 = Wreq::Client.new(**options)
response_3 = client_3.get(url, **options.slice(:header_order))
headers_3 = JSON.parse(response_3.text)["http2"]["sent_frames"][2]["headers"]
puts headers_3
puts "\n\n"

puts "Test #4: set options on client and get method except emulation"
client_4 = Wreq::Client.new(**options)
response_4 = client_4.get(url, **options.slice(:emulation))
headers_4 = JSON.parse(response_4.text)["http2"]["sent_frames"][2]["headers"]
puts headers_4
puts "\n\n"

puts "Test #5: set options on client and get method except headers"
client_5 = Wreq::Client.new(**options)
response_5 = client_5.get(url, **options.slice(:headers))
headers_5 = JSON.parse(response_5.text)["http2"]["sent_frames"][2]["headers"]
puts headers_5

Test # 2 and Test # 4 do not maintain header order.
Output:

Test #1: set options on client Only
:method: GET
:authority: tls.peet.ws
:scheme: https
:path: /api/all
a: 1
b: 2
c: 3
d: 4
sec-ch-ua: \"Chromium\";v=\"145\", \"Not;A=Brand\";v=\"24\", \"Microsoft Edge\";v=\"145\
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: \"macOS\
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: none
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br, zstd
accept-language: en-US,en;q=0.9
priority: u=0, i


Test #2: set options on client and get method
:method: GET
:authority: tls.peet.ws
:scheme: https
:path: /api/all
sec-ch-ua: \"Chromium\";v=\"145\", \"Not;A=Brand\";v=\"24\", \"Microsoft Edge\";v=\"145\
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: \"macOS\
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: none
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br, zstd
accept-language: en-US,en;q=0.9
priority: u=0, i
a: 1
b: 2
c: 3
d: 4


Test #3: set options on client and get method except header_order
:method: GET
:authority: tls.peet.ws
:scheme: https
:path: /api/all
a: 1
b: 2
c: 3
d: 4
sec-ch-ua: \"Chromium\";v=\"145\", \"Not;A=Brand\";v=\"24\", \"Microsoft Edge\";v=\"145\
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: \"macOS\
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: none
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br, zstd
accept-language: en-US,en;q=0.9
priority: u=0, i


Test #4: set options on client and get method except emulation
:method: GET
:authority: tls.peet.ws
:scheme: https
:path: /api/all
sec-ch-ua: \"Chromium\";v=\"145\", \"Not;A=Brand\";v=\"24\", \"Microsoft Edge\";v=\"145\
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: \"macOS\
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: none
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br, zstd
accept-language: en-US,en;q=0.9
priority: u=0, i
a: 1
b: 2
c: 3
d: 4


Test #5: set options on client and get method except headers
:method: GET
:authority: tls.peet.ws
:scheme: https
:path: /api/all
a: 1
b: 2
c: 3
d: 4
sec-ch-ua: \"Chromium\";v=\"145\", \"Not;A=Brand\";v=\"24\", \"Microsoft Edge\";v=\"145\
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: \"macOS\
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: none
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br, zstd
accept-language: en-US,en;q=0.9
priority: u=0, i
Dominant language
Rust
Stars
10
Forks
2
Avg merge
1h 33m
Merged PRs (30d)
3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.