When I enter the command:

$curl -basic https://www.google.com$

The output I receive is simply the text for the html page that we see when we visit the website.

but when I execute:

$curl -basic https://www.yahoo.com$

I receive no output, and the domain in my terminal changes from username@computer_name to Regional Redirectusername@computername.

What does this mean? I'm just not comfortable with that seeing I had thought what I was doing was sending a request to receive the text based content on the index page for a www domain. I apologize if this question is too vague, but I'd definitely like to know what the difference is here.

Thanks in advance


If You need always get HTML result I recommend use using curl flag "-L":

curl -L yahoo.com


curl -L https://www.yahoo.com

This flag force curl follow all URL redirects (graphical browser behavior). In case when site will redirect you couple of times, for example, to regional version, you always have chance get final HTML.

From curl man:

-L, --location

(HTTP) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place. If used together with -i, --include or -I, --head, headers from all requested pages will be shown. When authentication is used, curl only sends its credentials to the initial host. If a redirect takes curl to a different host, it won't be able to intercept the user+password. See also --location-trusted on how to change this. You can limit the amount of redirects to follow by using the --max-redirs option.

When curl follows a redirect and the request is not a plain GET (for example POST or PUT), it will do the following request with a GET if the HTTP response was 301, 302, or 303. If the response code was any other 3xx code, curl will re-send the following request using the same unmodified method.

You can tell curl to not change the non-GET request method to GET after a 30x response by using the dedicated options for that: --post301, --post302 and --post303.

|improve this answer|||||
  • Thanks curl -L yahoo.com returns the full HTML output – Adam Feb 14 '19 at 11:31

You should know that when you add the option -basic you actually set multiple parameters. What you might have wanted to do is --basic for basic authentication. Also the final $ sign is probably a typo.

If you execute the following, do you get the same unexpected behavior?

curl https://www.yahoo.com

|improve this answer|||||
  • Yeah the same thing occurs with out -basic appended – Adam Feb 14 '19 at 11:28
  • And the same when I append --basic – Adam Feb 14 '19 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.