text
stringlengths
0
2.02k
**Adam Stacoviak:** Yeah. Just the transfer of it.
**Daniel Stenberg:** Exactly. The transfer of whatever...
**Jerod Santo:** Whatever it is.
**Daniel Stenberg:** ...whatever it is.
**Adam Stacoviak:** It could be \[unintelligible 01:03:07.14\] who knows.
**Jerod Santo:** Now, you've shared this before, but it is worth noting that you can output to a file without a redirect, right? Without a pipe, or something like that. You can do a certain flag that will just download the file as is. It's similar to wget's default functionality. Do you wanna re-cover that for those wh...
**Daniel Stenberg:** Right... If you add the -O option, it will use the file import of the URL locally. So if \[unintelligible 01:03:33.09\] it will use that ending file.jpeg as a local file name, if you use -O.
**Jerod Santo:** And it will put the data in the file, yeah.
**Daniel Stenberg:** Yeah.
**Adam Stacoviak:** Way back when we first had you on the show you blew my mind, because -- this was the tail end of the show, too; it was like a magic feature, you described it as... And it was actually creating a Curl RC file, and in there putting --remote-name-all, so that it automatically passed -O by default.
**Daniel Stenberg:** \[01:04:08.17\] Yes, exactly, you can do that. That option is similar, but then that option will be used for all URLs. If you specify a number of URLs, it will apply that to all of them.
**Adam Stacoviak:** Which may not always be the desired case if you're a power Curl user. In my case, the majority of my use of Curl is that...
**Jerod Santo:** \[unintelligible 01:04:24.04\]
**Adam Stacoviak:** So it'd be a nice and smart default for me, but maybe not for everyone. That's cool.
**Daniel Stenberg:** Right. And when I created Curl, I actually wanted it to be more like the cat command in Curl; you cat a file and it outputs it to determine -- I wanted Curl to be that, but for a URL instead, so you would \[unintelligible 01:04:40.29\] I felt that was the UNIX philosophy, to just do that, so that's...
**Jerod Santo:** It totally is. Print to STDOUT and it integrates so much better with all the other command line tools when you do that.
**Daniel Stenberg:** But then you need an optional one to save it as a file.
**Jerod Santo:** You know, when your Coca-Cola and Pepsi comes along and they say "Well, we have Pepsi Zero", you have to say "Well, I can do Coke Zero, too." \[laughter\]
**Adam Stacoviak:** Touché. Touché.
**Jerod Santo:** Any other whizz-bang tricks for us before we move on?
**Daniel Stenberg:** I could possibly mention a pretty specialized option, it's called --next. It's a way to separate a different set of options. So you can use -- for example, if you wanna do get and post within the same command line, you can do Curl and a URL, and then you could use --next, and then you could us -d w...
**Jerod Santo:** So you're kind of chaining commands, but you're not doing separate commands.
**Daniel Stenberg:** Right.
**Jerod Santo:** It's one Curl command.
**Daniel Stenberg:** And by keeping the same command line, you can reuse connections, and stuff like that, so you can make it much more performant than you could otherwise. That's why it's there --
**Jerod Santo:** I see. So it keeps like a TCP connection open, versus if I did "curl this && curl that && curl this". Those would be new connections every time.
**Daniel Stenberg:** Exactly. Then you would have to set up a new connection each time...
**Jerod Santo:** I see...
**Daniel Stenberg:** ...which, of course, when you do two commands, once it doesn't matter; but if you're doing it in a loop, perhaps a million times, it will actually matter.
**Jerod Santo:** What about retrieving and maintaining session cookies, and stuff like that? Is it part of that as well?
**Daniel Stenberg:** Well, no, because if you wanna store cookies, you usually can do it two ways. You don't have to store cookies if you don't want. For example, if you wanna do it like that, you wanna do a lot of requests using this one command line, and just keep using cookies. You can just type -b and a file name t...
Or you can use -c, which creates a cookie jar as a file, so then you can store it on disk and then in repeated invokes you can read it back from the file. There are several ways to do it, depending on what you wanna do.
**Jerod Santo:** Okay.
**Daniel Stenberg:** If you wanna save the cookies for the next day, for example, you wanna save it in a file and use it again the next day, and update that file over and over every day, perhaps.
**Jerod Santo:** I think the common use case there is like your first request is a post to do some sort of sign-in, and then you store the cookie, and now you wanna get a protected page as that user. So if I use -b --
**Daniel Stenberg:** Like a login, and then you get the file, yes.
**Jerod Santo:** Yeah. I'm logging in, and now I'm getting a page that's private to that user.
**Daniel Stenberg:** That's a very common question also, because often you wanna get the login page first, because then you get a cookie. So you store that cookie in the cookie jar, and then you do the post, which makes the login, and you get updated cookies, and then you get that magic file you wanna \[unintelligible ...
**Jerod Santo:** Gotcha.
**Daniel Stenberg:** So that's usually three requests. So you just create the cookie file first, and then you use the cookie file and update it.
**Jerod Santo:** So are you doing -b on those, or are you doing --next?
**Daniel Stenberg:** -b is for reading, and -c for creating.
**Jerod Santo:** Oh, okay.
**Daniel Stenberg:** Typically, you do both, actually.
**Jerod Santo:** Okay.
**Daniel Stenberg:** Both reading and writing, if you wanna update the file as well.
**Jerod Santo:** \[01:08:04.07\] But if I did just --next, that would not work.
**Daniel Stenberg:** --next - it doesn't enable it; so you have to enable the cookies specifically.
**Jerod Santo:** Okay.
**Daniel Stenberg:** You would -b first for enabling the cookie, and then you could use -next and it would keep using the cookies.