HTTP reqwest sending cookie

reqwest header Cookie Client

The curl command

curl --cookie counter=42 ""

and the output:

  "args": {},
  "headers": {
    "Accept": "*/*",
    "Cookie": "counter=42",
    "Host": "",
    "User-Agent": "curl/8.2.1",
    "X-Amzn-Trace-Id": "Root=1-65b2455d-400413860278b6624dc30284"
  "origin": "",
  "url": ""

The dependencies


name = "simple-blocking-http-reqwest-sending-cookie"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at

reqwest = { version = "0.11", features = ["blocking", "json"] }
serde_json = "1.0"

The code


use reqwest::blocking::Client;

fn main() {
    let client = Client::new();

    match client.get("").header("Cookie", "counter=42").send() {
        Ok(resp) => {
            let data:  serde_json::Value = resp.json().unwrap();
            println!("{:#?}", data);
        Err(err) => eprintln!("{}", err),

The output

Object {
    "args": Object {},
    "headers": Object {
        "Accept": String("*/*"),
        "Cookie": String("counter=42"),
        "Host": String(""),
        "X-Amzn-Trace-Id": String("Root=1-65b244fe-37f44f2f5385618e52e9397b"),
    "origin": String(""),
    "url": String(""),

Related Pages

Reqwest the HTTP client library of Rust


Gabor Szabo (szabgab)

Gabor Szabo, the author of the Rust Maven web site maintains several Open source projects in Rust and while he still feels he has tons of new things to learn about Rust he already offers training courses in Rust and still teaches Python, Perl, git, GitHub, GitLab, CI, and testing.

Gabor Szabo