Support IPv4/IPv6 address for proxy option

This commit is contained in:
Fabrice Reix 2023-08-12 17:35:27 +02:00
parent cec0fb7160
commit cae200a77c
No known key found for this signature in database
GPG Key ID: BF5213154B2E7155
5 changed files with 19 additions and 4 deletions

View File

@ -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

View File

@ -5,5 +5,11 @@
<span class="line"><span class="string">proxy</span>: <span class="string">localhost:3128</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
<span class="line"><span class="string">From-Proxy</span>: <span class="string">Hello</span></span>
</span></span><span class="line"></span>
</code></pre>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span><span class="comment"># Using ipv4</span>
<span class="line"><span class="method">GET</span> <span class="url">http://127.0.0.1:8000/proxy</span></span>
<span class="line"><span class="section-header">[Options]</span></span>
<span class="line"><span class="string">proxy</span>: <span class="string">127.0.0.1:3128</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP</span> <span class="number">200</span></span>
<span class="line"><span class="string">From-Proxy</span>: <span class="string">Hello</span></span>
</span></span></code></pre>

View File

@ -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

View File

@ -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"}]}}]}

View File

@ -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,