I have a bunch of requests in my application that return html. So, there's a way to redirect the CURL output to my browser so it renders its content? Something like the code below (which does not work).
curl $MY_URL | firefox
Do you know any way of accomplish that?
From Firefox You get the site shown with Firefox's network tools. You then right-click on the specific request you want to repeat in the “Web Developer->Network” tool when you see the HTTP traffic, and in the menu that appears you select “Copy as cURL”.
curl can do almost every HTTP operation and transfer your favorite browser can. It can actually do a lot more than so as well, but in this chapter we will focus on the fact that you can use curl to reproduce, or script, what you would otherwise have to do manually with a browser.
The syntax for the curl command is as follows: curl [options] [URL...] In its simplest form, when invoked without any option, curl displays the specified resource to the standard output. The command will print the source code of the example.com homepage in your terminal window.
To follow redirect with Curl, use the -L or --location command-line option. This flag tells Curl to resend the request to the new address. When you send a POST request, and the server responds with one of the codes 301, 302, or 303, Curl will make the subsequent request using the GET method.
The following command worked for me using Cygwin (running under Win7) and Ubuntu 14.04.2:
curl http://www.rosstronics.biz | firefox "data:text/html;base64,$(base64 -w 0 <&0)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With