From cae200a77c3598c6f4d79f62b1d97a2b38d577e6 Mon Sep 17 00:00:00 2001 From: Fabrice Reix Date: Sat, 12 Aug 2023 17:35:27 +0200 Subject: [PATCH] Support IPv4/IPv6 address for proxy option --- integration/tests_ok/proxy.sh | 2 ++ integration/tests_ok/proxy_option.html | 10 ++++++++-- integration/tests_ok/proxy_option.hurl | 6 ++++++ integration/tests_ok/proxy_option.json | 2 +- packages/hurl_core/src/parser/sections.rs | 3 ++- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/integration/tests_ok/proxy.sh b/integration/tests_ok/proxy.sh index cc9538418..37bd6e852 100755 --- a/integration/tests_ok/proxy.sh +++ b/integration/tests_ok/proxy.sh @@ -1,3 +1,5 @@ #!/bin/bash set -Eeuo pipefail hurl tests_ok/proxy.hurl --proxy localhost:3128 --verbose +hurl tests_ok/proxy.hurl --proxy 127.0.0.1:3128 --verbose + diff --git a/integration/tests_ok/proxy_option.html b/integration/tests_ok/proxy_option.html index 16929b0dc..0ce41e7c0 100644 --- a/integration/tests_ok/proxy_option.html +++ b/integration/tests_ok/proxy_option.html @@ -5,5 +5,11 @@ proxy: localhost:3128 HTTP 200 From-Proxy: Hello - - + +# Using ipv4 +GET http://127.0.0.1:8000/proxy +[Options] +proxy: 127.0.0.1:3128 +HTTP 200 +From-Proxy: Hello + diff --git a/integration/tests_ok/proxy_option.hurl b/integration/tests_ok/proxy_option.hurl index abef0b7cc..731ae4aa9 100644 --- a/integration/tests_ok/proxy_option.hurl +++ b/integration/tests_ok/proxy_option.hurl @@ -6,3 +6,9 @@ proxy: localhost:3128 HTTP 200 From-Proxy: Hello +# Using ipv4 +GET http://127.0.0.1:8000/proxy +[Options] +proxy: 127.0.0.1:3128 +HTTP 200 +From-Proxy: Hello diff --git a/integration/tests_ok/proxy_option.json b/integration/tests_ok/proxy_option.json index bf4aa6b1f..f54c26644 100644 --- a/integration/tests_ok/proxy_option.json +++ b/integration/tests_ok/proxy_option.json @@ -1 +1 @@ -{"entries":[{"request":{"method":"GET","url":"http://127.0.0.1:8000/proxy","options":[{"name":"proxy","value":"localhost:3128"}]},"response":{"status":200,"headers":[{"name":"From-Proxy","value":"Hello"}]}}]} +{"entries":[{"request":{"method":"GET","url":"http://127.0.0.1:8000/proxy","options":[{"name":"proxy","value":"localhost:3128"}]},"response":{"status":200,"headers":[{"name":"From-Proxy","value":"Hello"}]}},{"request":{"method":"GET","url":"http://127.0.0.1:8000/proxy","options":[{"name":"proxy","value":"127.0.0.1:3128"}]},"response":{"status":200,"headers":[{"name":"From-Proxy","value":"Hello"}]}}]} diff --git a/packages/hurl_core/src/parser/sections.rs b/packages/hurl_core/src/parser/sections.rs index d2ea4cd11..ea2b70240 100644 --- a/packages/hurl_core/src/parser/sections.rs +++ b/packages/hurl_core/src/parser/sections.rs @@ -484,7 +484,8 @@ fn option_very_verbose(reader: &mut Reader) -> ParseResult<'static, OptionKind> fn proxy(reader: &mut Reader) -> ParseResult<'static, String> { let start = reader.state.clone(); - let name = reader.read_while(|c| c.is_alphanumeric() || *c == ':'); + let name = reader + .read_while(|c| c.is_alphanumeric() || *c == ':' || *c == '.' || *c == '[' || *c == ']'); if name.is_empty() { return Err(Error { pos: start.pos,