Re: Outputting URL components

Timothe Litt via curl-users <[email protected]>
Newsgroups gmane.comp.web.curl.general
Message-ID <[email protected]>
On 30-Mar-23 03:28, Daniel Stenberg via curl-users wrote:
> On Wed, 29 Mar 2023, Rich Gray via curl-users wrote:
>
>> If it's not already possible, it seems like it would be useful to 
>> give curl a URL solely for the purpose of write outs (no transfer 
>> operation).  Curl would be able to function as a URL parser for scripts.
>>
>>  curl --noop http://www.example.com:123/test -w'%{url.port}\n'
>>
>> would echo out 123 on a line by itself.
>>
>> --noop could also be useful for testing a curl command line for 
>> validity without doing a transfer.  (Could this speed up some tests?)
>
> Yeah, that exact thought crossed my mind as well. I'm hesitating 
> though, because I'm a little afraid of where such an option might take 
> us.
>
>
Hesitation is appropriate.

This seems rather limited, since you can't get much without doing some 
(usually network) IO.  Resolving a name requires DNS, getting an 
effective URL requires following redirects, resolving service names to 
ports requires access to /etc/services, ... and obviously you can't get 
transfer statistics or most of the other -w parameters.

If you're not going to do a transfer, what's the point?  Most use cases 
evaporate on inspection.

This is rather like the file tests (is a file readable? Writable?)  It 
turns out that while they superficially work, it's pretty common to pass 
the test but have an actual open fail.  And vice-versa.  (E.g. where the 
test uses stat's mode, but there's an ACL.  Or an anti-virus block.  
Or...)  The only reliable way to know if an operation will work is to 
try it.

It's not clear that curl ought to be a text processor.

But if you go there anyhow, use a useful name, e.g. --parse-only.  The 
request isn't a NOP.  And there are protocols that actually have a NOP 
operation defined..


Timothe Litt
ACM Distinguished Engineer
--------------------------
This communication may not represent the ACM or my employer's views,
if any, on the matters discussed.

-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
OpenPGP_signature (application/pgp-signature, 495 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.