Orange-OpenSource / hurl

Hurl, run and test HTTP requests with plain text.
https://hurl.dev
Apache License 2.0
13.02k stars 486 forks source link

Support ip query for getting resolved response IP #3106

Open jcamiel opened 3 months ago

jcamiel commented 3 months ago

A proposal to add an ip query

GET https://foo.com
HTTP 200
[Asserts]
ip == "192.168.0.1"
GET https://foo.com
HTTP 200
[Asserts]
ip matches /2001:0000:130F:0000:0000:09C0:876A:\d*/

In libcurl the corresponding call is CURLINFO_PRIMARY_IP.

There is also a CURLINFO_LOCAL_IP but I've the impression that user expectation is more on primary ip.

Question: what's about port ? Does the query ip exctract the IP address and the port (192.168.0.01:8080), or do we have a separate port query that we can do latter?

GET https://foo.com
HTTP 200
[Asserts]
ip == "192.168.0.1"
port == 8080

With ip/portas separated queries, we can also have isIPv6 and isIPv4 predicates:

GET https://foo.com
HTTP 200
[Asserts]
ip isIPv6

Idea from @lepapareil 😎