Skip to content

Commit 1409b07

Browse files
committed
Add http1.0 option in config_file
1 parent 558c5f8 commit 1409b07

5 files changed

Lines changed: 30 additions & 0 deletions

File tree

docs/spec/options/hurl/http10.option

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ long: http1.0
33
short: 0
44
help: Tell Hurl to use HTTP version 1.0
55
help_heading: HTTP options
6+
config_file: true
67
env_var: HURL_HTTP10
78
---
89
Tells Hurl to use HTTP version 1.0 instead of using its internally preferred HTTP version.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--http1.0
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Set-StrictMode -Version latest
2+
$ErrorActionPreference = 'Stop'
3+
4+
$env:XDG_CONFIG_HOME = "$PSScriptRoot/config_10"
5+
6+
hurl tests_ok/http_version/http_version_10.hurl
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -Eeuo pipefail
3+
4+
XDG_CONFIG_HOME=$(dirname "$0")/config_10
5+
export XDG_CONFIG_HOME
6+
7+
hurl tests_ok/http_version/http_version_10.hurl

packages/hurl/src/cli/options/config_file/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ fn parse_option(reader: &mut Reader, options: &mut CliOptions) -> Result<(), Con
173173
options.insecure = true;
174174
Ok(())
175175
}
176+
"http1.0" => {
177+
expect_no_value(reader)?;
178+
options.http_version = Some(HttpVersion::V10);
179+
Ok(())
180+
}
176181
"http1.1" => {
177182
expect_no_value(reader)?;
178183
options.http_version = Some(HttpVersion::V11);
@@ -394,6 +399,16 @@ mod tests {
394399
assert_eq!(reader.cursor().pos, Pos::new(2, 1));
395400
}
396401

402+
#[test]
403+
fn test_parse_option_http10() {
404+
let mut reader = Reader::new("--http1.0\n");
405+
let mut options = CliOptions::default();
406+
assert!(options.http_version.is_none());
407+
assert!(parse_option(&mut reader, &mut options).is_ok());
408+
assert_eq!(options.http_version, Some(HttpVersion::V10));
409+
assert_eq!(reader.cursor().pos, Pos::new(2, 1));
410+
}
411+
397412
#[test]
398413
fn test_parse_option_follow_location() {
399414
let mut reader = Reader::new("--location\n");

0 commit comments

Comments
 (0)