mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-23 09:44:22 +03:00
Add --http1.1 option
This commit is contained in:
parent
17ec6c8b1a
commit
411f0ed8f5
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -Eeuo pipefail
|
||||
hurl --http1.0 tests_ok/http_version.hurl
|
@ -1,3 +1,3 @@
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
hurl --http1.0 tests_ok/http_version.hurl
|
||||
hurl --http1.0 tests_ok/http_version_10.hurl
|
3
integration/tests_ok/http_version_10.sh
Executable file
3
integration/tests_ok/http_version_10.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
set -Eeuo pipefail
|
||||
hurl --http1.0 tests_ok/http_version_10.hurl
|
1
integration/tests_ok/http_version_11.curl
Normal file
1
integration/tests_ok/http_version_11.curl
Normal file
@ -0,0 +1 @@
|
||||
curl --http1.1 'http://localhost:8000/http_version/11'
|
3
integration/tests_ok/http_version_11.html
Normal file
3
integration/tests_ok/http_version_11.html
Normal file
@ -0,0 +1,3 @@
|
||||
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/http_version/11</span></span>
|
||||
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
|
||||
</span></span></code></pre>
|
2
integration/tests_ok/http_version_11.hurl
Normal file
2
integration/tests_ok/http_version_11.hurl
Normal file
@ -0,0 +1,2 @@
|
||||
GET http://localhost:8000/http_version/11
|
||||
HTTP 200
|
1
integration/tests_ok/http_version_11.json
Normal file
1
integration/tests_ok/http_version_11.json
Normal file
@ -0,0 +1 @@
|
||||
{"entries":[{"request":{"method":"GET","url":"http://localhost:8000/http_version/11"},"response":{"status":200}}]}
|
1
integration/tests_ok/http_version_11.out
Normal file
1
integration/tests_ok/http_version_11.out
Normal file
@ -0,0 +1 @@
|
||||
HTTP/1.1
|
3
integration/tests_ok/http_version_11.ps1
Executable file
3
integration/tests_ok/http_version_11.ps1
Executable file
@ -0,0 +1,3 @@
|
||||
Set-StrictMode -Version latest
|
||||
$ErrorActionPreference = 'Stop'
|
||||
hurl --http1.1 tests_ok/http_version_11.hurl
|
3
integration/tests_ok/http_version_11.sh
Executable file
3
integration/tests_ok/http_version_11.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
set -Eeuo pipefail
|
||||
hurl --http1.1 tests_ok/http_version_11.hurl
|
@ -169,6 +169,13 @@ pub fn http10() -> clap::Arg {
|
||||
.action(ArgAction::SetTrue)
|
||||
}
|
||||
|
||||
pub fn http11() -> clap::Arg {
|
||||
clap::Arg::new("http11")
|
||||
.long("http1.1")
|
||||
.help("Tells curl to use HTTP version 1.1")
|
||||
.action(ArgAction::SetTrue)
|
||||
}
|
||||
|
||||
pub fn include() -> clap::Arg {
|
||||
clap::Arg::new("include")
|
||||
.short('i')
|
||||
|
@ -170,7 +170,9 @@ pub fn html_dir(arg_matches: &ArgMatches) -> Result<Option<PathBuf>, OptionsErro
|
||||
}
|
||||
|
||||
pub fn http_version(arg_matches: &ArgMatches) -> Option<HttpVersion> {
|
||||
if has_flag(arg_matches, "http10") {
|
||||
if has_flag(arg_matches, "http11") {
|
||||
Some(HttpVersion::V11)
|
||||
} else if has_flag(arg_matches, "http10") {
|
||||
Some(HttpVersion::V10)
|
||||
} else {
|
||||
None
|
||||
|
@ -106,12 +106,14 @@ pub enum ErrorFormat {
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum HttpVersion {
|
||||
V10,
|
||||
V11,
|
||||
}
|
||||
|
||||
impl From<HttpVersion> for http::HttpVersion {
|
||||
fn from(value: HttpVersion) -> Self {
|
||||
match value {
|
||||
HttpVersion::V10 => http::HttpVersion::Http10,
|
||||
HttpVersion::V11 => http::HttpVersion::Http11,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -159,6 +161,7 @@ pub fn parse() -> Result<Options, OptionsError> {
|
||||
.arg(commands::follow_location())
|
||||
.arg(commands::glob())
|
||||
.arg(commands::http10())
|
||||
.arg(commands::http11())
|
||||
.arg(commands::ignore_asserts())
|
||||
.arg(commands::include())
|
||||
.arg(commands::input_files())
|
||||
|
@ -120,8 +120,10 @@ impl ClientOptions {
|
||||
if self.insecure {
|
||||
arguments.push("--insecure".to_string());
|
||||
}
|
||||
if self.http_version == Some(HttpVersion::Http10) {
|
||||
arguments.push("--http1.0".to_string());
|
||||
match self.http_version {
|
||||
Some(HttpVersion::Http10) => arguments.push("--http1.0".to_string()),
|
||||
Some(HttpVersion::Http11) => arguments.push("--http1.1".to_string()),
|
||||
_ => {}
|
||||
}
|
||||
if self.follow_location {
|
||||
arguments.push("--location".to_string());
|
||||
|
Loading…
Reference in New Issue
Block a user