zapreq 0.1.7

A fast, friendly HTTP client for the terminal
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
use regex::Regex;
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum HeaderSource {
    User,
    Auto,
    Preset,
    Environment,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct Header {
    pub name: String,
    pub value: String,
    pub enabled: bool,
    pub sensitive: bool,
    pub source: HeaderSource,
}

#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum HeaderValidationSeverity {
    Info,
    Warning,
    Error,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct HeaderWarning {
    pub name: Option<String>,
    pub message: String,
    pub severity: HeaderValidationSeverity,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct HeaderSuggestion {
    pub name: String,
    pub description: String,
    pub common_values: Vec<String>,
    pub sensitive_by_default: bool,
}

const HEADER_SUGGESTION_DATA: &[(&str, &str, &[&str], bool)] = &[
    (
        "Authorization",
        "Credentials for bearer, basic, and API token flows.",
        &["Bearer <token>", "Basic <base64>", "ApiKey <key>"],
        true,
    ),
    (
        "Content-Type",
        "Declares the request body media type.",
        &[
            "application/json",
            "application/x-www-form-urlencoded",
            "multipart/form-data",
            "text/plain",
            "application/xml",
        ],
        false,
    ),
    (
        "Accept",
        "Declares which response media types the client accepts.",
        &["application/json", "*/*", "text/plain", "application/xml"],
        false,
    ),
    (
        "User-Agent",
        "Identifies the client application to the server.",
        &["zapreq/<version>"],
        false,
    ),
    (
        "X-API-Key",
        "Carries an API key when bearer auth is not used.",
        &["<api-key>"],
        true,
    ),
    (
        "X-Request-ID",
        "Correlates a client request across services.",
        &["<request-id>"],
        false,
    ),
    (
        "X-Correlation-ID",
        "Correlates a workflow or trace across multiple requests.",
        &["<correlation-id>"],
        false,
    ),
    (
        "Idempotency-Key",
        "Prevents duplicate mutations for retryable writes.",
        &["<uuid>"],
        false,
    ),
    (
        "Cache-Control",
        "Controls cache behavior for requests and responses.",
        &["no-cache", "no-store", "max-age=0"],
        false,
    ),
    (
        "If-None-Match",
        "Sends an ETag for cache revalidation.",
        &["W/\"etag-value\"", "\"etag-value\""],
        false,
    ),
    (
        "If-Modified-Since",
        "Sends a timestamp for cache revalidation.",
        &["Wed, 21 Oct 2015 07:28:00 GMT"],
        false,
    ),
    (
        "Origin",
        "Identifies the browser origin for CORS requests.",
        &["https://app.example.com"],
        false,
    ),
    (
        "Referer",
        "Identifies the previous page or request source.",
        &["https://app.example.com/page"],
        false,
    ),
    (
        "Cookie",
        "Carries stateful cookie values to the server.",
        &["session=<token>"],
        true,
    ),
    (
        "Accept-Encoding",
        "Negotiates supported compression formats.",
        &["gzip, br, deflate"],
        false,
    ),
    (
        "Accept-Language",
        "Negotiates preferred response languages.",
        &["en-US,en;q=0.9"],
        false,
    ),
];

pub fn header_suggestions() -> Vec<HeaderSuggestion> {
    HEADER_SUGGESTION_DATA
        .iter()
        .map(|(name, description, values, sensitive)| HeaderSuggestion {
            name: (*name).to_string(),
            description: (*description).to_string(),
            common_values: values.iter().map(|value| (*value).to_string()).collect(),
            sensitive_by_default: *sensitive,
        })
        .collect()
}

pub fn common_header_names() -> Vec<String> {
    header_suggestions()
        .into_iter()
        .map(|entry| entry.name)
        .collect()
}

/// Dynamic value suggestions based on selected header key.
pub fn get_value_suggestions(name: &str) -> Vec<String> {
    header_suggestions()
        .into_iter()
        .find(|suggestion| suggestion.name.eq_ignore_ascii_case(name))
        .map(|suggestion| suggestion.common_values)
        .unwrap_or_default()
}

/// Checks if a header key is sensitive.
pub fn is_sensitive_header(name: &str) -> bool {
    let lower = name.to_ascii_lowercase();
    matches!(
        lower.trim(),
        "authorization"
            | "proxy-authorization"
            | "x-api-key"
            | "api-key"
            | "cookie"
            | "set-cookie"
            | "x-auth-token"
            | "x-csrf-token"
    )
}

/// Mask sensitive values in headers safely.
pub fn mask_header_value(name: &str, value: &str) -> String {
    if !is_sensitive_header(name) {
        return value.to_string();
    }
    if value.is_empty() {
        return String::new();
    }

    if let Some((scheme, rest)) = value.split_once(' ') {
        if !rest.is_empty() {
            return format!("{} {}", scheme, mask_raw_value(rest));
        }
    }

    if let Some((k, v)) = value.split_once('=') {
        if !v.is_empty() {
            return format!("{}={}", k, mask_raw_value(v));
        }
    }

    mask_raw_value(value)
}

fn mask_raw_value(value: &str) -> String {
    if value.len() <= 5 {
        "****".to_string()
    } else {
        format!("{}...****", &value[..5])
    }
}

pub fn headers_from_parsed_items(
    parsed_items: &[crate::items::RequestItem],
    source: HeaderSource,
) -> Vec<Header> {
    let mut headers = Vec::new();
    for item in parsed_items {
        if let crate::items::RequestItem::Header { key, value } = item {
            headers.push(Header {
                name: key.clone(),
                value: value.clone(),
                enabled: true,
                sensitive: is_sensitive_header(key),
                source: source.clone(),
            });
        }
    }
    headers
}

pub fn headers_from_curl_headers(curl_headers: &[String], source: HeaderSource) -> Vec<Header> {
    let mut headers = Vec::new();
    for raw in curl_headers {
        if let Some((key, value)) = raw.split_once(':') {
            let key = key.trim();
            let value = value.trim();
            headers.push(Header {
                name: key.to_string(),
                value: value.to_string(),
                enabled: true,
                sensitive: is_sensitive_header(key),
                source: source.clone(),
            });
        }
    }
    headers
}

pub fn header_items(headers: &[Header]) -> Vec<String> {
    headers
        .iter()
        .filter(|header| header.enabled && !header.name.trim().is_empty())
        .map(|header| format!("{}:{}", header.name, header.value))
        .collect()
}

/// Auto headers generation for missing defaults.
pub fn get_auto_headers(body_type: &str) -> Vec<Header> {
    let mut auto = Vec::new();
    let version = env!("CARGO_PKG_VERSION");

    auto.push(Header {
        name: "User-Agent".to_string(),
        value: format!("zapreq/{}", version),
        enabled: true,
        sensitive: false,
        source: HeaderSource::Auto,
    });

    match body_type {
        "json" => {
            auto.push(Header {
                name: "Content-Type".to_string(),
                value: "application/json".to_string(),
                enabled: true,
                sensitive: false,
                source: HeaderSource::Auto,
            });
            auto.push(Header {
                name: "Accept".to_string(),
                value: "application/json".to_string(),
                enabled: true,
                sensitive: false,
                source: HeaderSource::Auto,
            });
        }
        "form" => {
            auto.push(Header {
                name: "Content-Type".to_string(),
                value: "application/x-www-form-urlencoded".to_string(),
                enabled: true,
                sensitive: false,
                source: HeaderSource::Auto,
            });
            auto.push(Header {
                name: "Accept".to_string(),
                value: "*/*".to_string(),
                enabled: true,
                sensitive: false,
                source: HeaderSource::Auto,
            });
        }
        "multipart" => {
            // Note: let the client library set the exact boundary, but we still define the MIME type
            auto.push(Header {
                name: "Content-Type".to_string(),
                value: "multipart/form-data".to_string(),
                enabled: true,
                sensitive: false,
                source: HeaderSource::Auto,
            });
            auto.push(Header {
                name: "Accept".to_string(),
                value: "*/*".to_string(),
                enabled: true,
                sensitive: false,
                source: HeaderSource::Auto,
            });
        }
        _ => {
            auto.push(Header {
                name: "Accept".to_string(),
                value: "*/*".to_string(),
                enabled: true,
                sensitive: false,
                source: HeaderSource::Auto,
            });
        }
    }

    auto
}

/// Merge order implementation: Preset -> Environment -> User -> Auto (when missing).
pub fn merge_headers(
    presets: &[Header],
    environments: &[Header],
    users: &[Header],
    autos: &[Header],
) -> Vec<Header> {
    let user_keys: HashSet<String> = users
        .iter()
        .filter(|h| h.enabled)
        .map(|h| h.name.to_ascii_lowercase())
        .collect();

    let env_keys: HashSet<String> = environments
        .iter()
        .filter(|h| h.enabled)
        .map(|h| h.name.to_ascii_lowercase())
        .collect();

    let preset_keys: HashSet<String> = presets
        .iter()
        .filter(|h| h.enabled)
        .map(|h| h.name.to_ascii_lowercase())
        .collect();

    let mut merged = Vec::new();

    // 1. Preset headers (if not overridden by User or Env)
    for h in presets {
        let key = h.name.to_ascii_lowercase();
        if !user_keys.contains(&key) && !env_keys.contains(&key) {
            let mut header = h.clone();
            header.source = HeaderSource::Preset;
            merged.push(header);
        }
    }

    // 2. Env headers (if not overridden by User)
    for h in environments {
        let key = h.name.to_ascii_lowercase();
        if !user_keys.contains(&key) {
            let mut header = h.clone();
            header.source = HeaderSource::Environment;
            merged.push(header);
        }
    }

    // 3. User headers
    for h in users {
        let mut header = h.clone();
        header.source = HeaderSource::User;
        merged.push(header);
    }

    // 4. Auto headers for missing defaults
    for h in autos {
        let key = h.name.to_ascii_lowercase();
        if !user_keys.contains(&key) && !env_keys.contains(&key) && !preset_keys.contains(&key) {
            let mut header = h.clone();
            header.source = HeaderSource::Auto;
            merged.push(header);
        }
    }

    merged
}

/// Validates list of headers and returns warnings/errors.
pub fn validate_headers(
    headers: &[Header],
    body_type: &str,
    body_content: Option<&str>,
    is_unencrypted: bool,
) -> Vec<HeaderWarning> {
    let mut warnings = Vec::new();
    let mut counts: HashMap<String, usize> = HashMap::new();
    let token_re = header_name_token_regex();

    for h in headers {
        if !h.enabled {
            continue;
        }

        let name_trimmed = h.name.trim();
        let key = name_trimmed.to_ascii_lowercase();
        *counts.entry(key.clone()).or_insert(0) += 1;

        if name_trimmed.is_empty() {
            push_header_warning(
                &mut warnings,
                Some(h.name.clone()),
                "Header name cannot be empty.".to_string(),
                HeaderValidationSeverity::Error,
            );
            continue;
        }

        if !token_re.is_match(name_trimmed) {
            push_header_warning(
                &mut warnings,
                Some(h.name.clone()),
                format!(
                    "Header name '{}' contains invalid characters.",
                    name_trimmed
                ),
                HeaderValidationSeverity::Error,
            );
        }

        if h.value.trim().is_empty() {
            push_header_warning(
                &mut warnings,
                Some(h.name.clone()),
                format!("Header '{}' is defined without a value.", h.name),
                HeaderValidationSeverity::Warning,
            );
        }

        push_typo_warning(&mut warnings, h, &key);
        push_sensitive_transport_warning(&mut warnings, h, is_unencrypted);
    }

    push_duplicate_warnings(&mut warnings, headers, &counts);
    push_json_body_warnings(&mut warnings, headers, body_type, body_content);

    warnings
}

fn header_name_token_regex() -> Regex {
    Regex::new(r"^[A-Za-z0-9!#\$%&'\*\+\-\.\^_`\|~]+$").expect("regex should compile")
}

fn push_header_warning(
    warnings: &mut Vec<HeaderWarning>,
    name: Option<String>,
    message: String,
    severity: HeaderValidationSeverity,
) {
    warnings.push(HeaderWarning {
        name,
        message,
        severity,
    });
}

fn push_typo_warning(warnings: &mut Vec<HeaderWarning>, header: &Header, key: &str) {
    let message = match key {
        "contenttype" => Some("Did you mean 'Content-Type'?"),
        "authorisation" | "authentication" => Some("Did you mean 'Authorization'?"),
        "content-length" => Some(
            "Manually setting Content-Length is not recommended; let the HTTP client handle it.",
        ),
        _ => None,
    };
    if let Some(message) = message {
        push_header_warning(
            warnings,
            Some(header.name.clone()),
            message.to_string(),
            HeaderValidationSeverity::Warning,
        );
    }
}

fn push_sensitive_transport_warning(
    warnings: &mut Vec<HeaderWarning>,
    header: &Header,
    is_unencrypted: bool,
) {
    if !is_unencrypted || !is_sensitive_header(&header.name) {
        return;
    }

    push_header_warning(
        warnings,
        Some(header.name.clone()),
        format!(
            "Sensitive header '{}' is being sent over unencrypted HTTP.",
            header.name
        ),
        HeaderValidationSeverity::Warning,
    );
}

fn push_duplicate_warnings(
    warnings: &mut Vec<HeaderWarning>,
    headers: &[Header],
    counts: &HashMap<String, usize>,
) {
    for (key, count) in counts {
        if *count <= 1 {
            continue;
        }

        let original_name = headers
            .iter()
            .find(|header| header.name.to_ascii_lowercase() == *key)
            .map(|header| header.name.as_str())
            .unwrap_or(key);
        let (message, severity) = duplicate_warning_details(key, original_name);
        push_header_warning(warnings, Some(original_name.to_string()), message, severity);
    }
}

fn duplicate_warning_details(key: &str, original_name: &str) -> (String, HeaderValidationSeverity) {
    match key {
        "authorization" | "content-type" | "host" | "content-length" => (
            format!("Problematic duplicate header '{}' detected.", original_name),
            HeaderValidationSeverity::Warning,
        ),
        _ => (
            format!("Duplicate header '{}' detected.", original_name),
            HeaderValidationSeverity::Info,
        ),
    }
}

fn push_json_body_warnings(
    warnings: &mut Vec<HeaderWarning>,
    headers: &[Header],
    body_type: &str,
    body_content: Option<&str>,
) {
    let has_json_content_type = headers.iter().any(|header| {
        header.enabled
            && header.name.eq_ignore_ascii_case("content-type")
            && header
                .value
                .to_ascii_lowercase()
                .contains("application/json")
    });

    if body_type == "json" && !has_json_content_type {
        push_header_warning(
            warnings,
            None,
            "JSON body fields are present but Content-Type is not set to application/json."
                .to_string(),
            HeaderValidationSeverity::Warning,
        );
    }

    let Some(body) = body_content else {
        return;
    };
    let body_trimmed = body.trim();
    if !has_json_content_type || body_trimmed.is_empty() {
        return;
    }
    if serde_json::from_str::<serde_json::Value>(body_trimmed).is_ok() {
        return;
    }

    push_header_warning(
        warnings,
        Some("Content-Type".to_string()),
        "Content-Type is application/json but body content is not valid JSON.".to_string(),
        HeaderValidationSeverity::Error,
    );
}

/// Builds request headers using the full CLI defaults, curl headers, presets, profile, and body content.
pub fn build_headers_from_cli(
    args: &crate::cli::CliArgs,
    parsed_items: &[crate::items::RequestItem],
    env_headers: &std::collections::HashMap<String, String>,
) -> anyhow::Result<Vec<Header>> {
    let mut preset_headers = Vec::new();
    for p in &args.preset {
        if let Ok(loaded) = crate::header_presets::load_preset(p) {
            preset_headers.extend(loaded);
        }
    }

    let mut environments = Vec::new();
    for (k, v) in env_headers {
        let sensitive = is_sensitive_header(k);
        environments.push(Header {
            name: k.clone(),
            value: v.clone(),
            enabled: true,
            sensitive,
            source: HeaderSource::Environment,
        });
    }

    let mut users = headers_from_parsed_items(parsed_items, HeaderSource::User);
    users.extend(headers_from_curl_headers(
        &args.curl_headers,
        HeaderSource::User,
    ));

    let collected = crate::items::collect_from_parsed(parsed_items)?;
    let has_file_uploads = !collected.files.is_empty();
    let body_type = if args.multipart || has_file_uploads {
        "multipart"
    } else if args.form {
        "form"
    } else if !collected.data_strings.is_empty() || !collected.data_json.is_empty() {
        "json"
    } else {
        "none"
    };

    let autos = get_auto_headers(body_type);

    Ok(merge_headers(
        &preset_headers,
        &environments,
        &users,
        &autos,
    ))
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_mask_header_value() {
        assert_eq!(
            mask_header_value("Authorization", "Bearer token123456"),
            "Bearer token...****"
        );
        assert_eq!(
            mask_header_value("X-API-Key", "sk_live_12345"),
            "sk_li...****"
        );
        assert_eq!(
            mask_header_value("Cookie", "session=abcdefg"),
            "session=abcde...****"
        );
        assert_eq!(
            mask_header_value("Accept", "application/json"),
            "application/json"
        );
    }

    #[test]
    fn test_header_suggestions_registry() {
        let suggestions = header_suggestions();
        let authorization = suggestions
            .iter()
            .find(|entry| entry.name == "Authorization")
            .expect("authorization suggestion should exist");
        assert!(authorization.sensitive_by_default);
        assert!(authorization
            .common_values
            .contains(&"Bearer <token>".to_string()));
        assert!(common_header_names().contains(&"Content-Type".to_string()));
    }

    #[test]
    fn test_merge_headers() {
        let presets = vec![
            Header {
                name: "X-Tag".to_string(),
                value: "preset".to_string(),
                enabled: true,
                sensitive: false,
                source: HeaderSource::Preset,
            },
            Header {
                name: "Accept".to_string(),
                value: "text/xml".to_string(),
                enabled: true,
                sensitive: false,
                source: HeaderSource::Preset,
            },
        ];
        let environments = vec![Header {
            name: "Accept".to_string(),
            value: "application/json".to_string(),
            enabled: true,
            sensitive: false,
            source: HeaderSource::Environment,
        }];
        let users = vec![Header {
            name: "X-My-Header".to_string(),
            value: "user".to_string(),
            enabled: true,
            sensitive: false,
            source: HeaderSource::User,
        }];
        let autos = vec![Header {
            name: "User-Agent".to_string(),
            value: "ZapReq/1.0".to_string(),
            enabled: true,
            sensitive: false,
            source: HeaderSource::Auto,
        }];

        let merged = merge_headers(&presets, &environments, &users, &autos);
        assert_eq!(merged.len(), 4);
        assert_eq!(merged[0].name, "X-Tag"); // Preset
        assert_eq!(merged[1].name, "Accept"); // Environment overrides Preset
        assert_eq!(merged[1].value, "application/json");
        assert_eq!(merged[2].name, "X-My-Header"); // User
        assert_eq!(merged[3].name, "User-Agent"); // Auto
    }

    #[test]
    fn test_validate_headers() {
        let headers = vec![
            Header {
                name: "ContentType".to_string(),
                value: "application/json".to_string(),
                enabled: true,
                sensitive: false,
                source: HeaderSource::User,
            },
            Header {
                name: "Authorization".to_string(),
                value: "Bearer token".to_string(),
                enabled: true,
                sensitive: true,
                source: HeaderSource::User,
            },
            Header {
                name: "Authorization".to_string(),
                value: "Bearer token2".to_string(),
                enabled: true,
                sensitive: true,
                source: HeaderSource::User,
            },
        ];

        let warnings = validate_headers(&headers, "none", None, true);
        assert!(warnings
            .iter()
            .any(|w| w.message.contains("Did you mean 'Content-Type'?")));
        assert!(warnings.iter().any(|w| w
            .message
            .contains("Problematic duplicate header 'Authorization' detected.")));
        assert!(warnings.iter().any(|w| w
            .message
            .contains("Sensitive header 'Authorization' is being sent over unencrypted HTTP.")));
    }

    #[test]
    fn test_header_items_preserve_enabled_order() {
        let headers = vec![
            Header {
                name: "X-Trace".to_string(),
                value: "one".to_string(),
                enabled: true,
                sensitive: false,
                source: HeaderSource::User,
            },
            Header {
                name: "X-Trace".to_string(),
                value: "two".to_string(),
                enabled: true,
                sensitive: false,
                source: HeaderSource::User,
            },
            Header {
                name: "Disabled".to_string(),
                value: "ignored".to_string(),
                enabled: false,
                sensitive: false,
                source: HeaderSource::User,
            },
        ];

        assert_eq!(
            header_items(&headers),
            vec!["X-Trace:one".to_string(), "X-Trace:two".to_string()]
        );
    }
}