DEV Community

K-Sato
K-Sato

Posted on

Basic curl options

Overview

Here are some super basic curl command options all web-application-developers should know.
If there is/are any other command option/options, you think, should be on the list, plz leave a comment below with the option/options.

Add headers

You can use -H to add headers to your request.

$ curl -H "Content-Type: application/json" http://localhost:8888
Enter fullscreen mode Exit fullscreen mode

Make a POST request with Parameters

You can make a post request with parameters with the -d (-data) flag.
You can specify the method you want to use with -X. In this case, you are specifying to use the POST method.

$ curl -d '{"name":"value1", "content":"value2"}'  -X POST http://localhost:3000
Enter fullscreen mode Exit fullscreen mode

Get verbose response

You can get verbose response with the -v option. The -v stands for -verbose.

$ curl -v http://localhost:8888
Enter fullscreen mode Exit fullscreen mode

Fetch only the HTTP headers

You can use -I/--head flag to only fetch the headers.

$ curl -I http://localhost:8888
Enter fullscreen mode Exit fullscreen mode

Add cookies

You can pass the data to the HTTP server as a cookie with the -b/--cookie command.
NOTE that the file specified with -b/--cookie is only used as input. No cookies will be stored in the file. To store cookies, use the -c/--cookie-jar option

$ curl -c cookie.txt -b cookie.txt -b "name=value" http://example.com
Enter fullscreen mode Exit fullscreen mode

Send Data like sending them via forms

This lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using the content-type multipart/form-data according to RFC1867.

$ curl -F title="Test" -F author="Test" -F attachment-file=@test.txt http://localhost:8880
Enter fullscreen mode Exit fullscreen mode

Resources

Here are some resources to know more about the curl command.

Top comments (56)

Collapse
 
pranay_rauthu profile image
pranay rauthu

writing curl commands is pain. I have created a tool to generate them.

pranayrauthu.github.io/fetcher/#/curl

Collapse
 
oliverjamie0404 profile image
Oliver Jamie

I appreciate the provided list of basic curl command options for Linux beginners. These options, such as adding headers, making POST requests with parameters, getting verbose responses, fetching only the HTTP headers, and adding build now gg cookies, are essential for web application developers.

Collapse
 
ronger profile image
ronger • Edited

Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon! Suika

Collapse
 
ronger profile image
ronger

Wow! This could be one of the most useful blogs we have ever come across on thesubject. Actually excellent info! I’m also an expert in this topic so I can understand your effort. Infinite Craft Game

Collapse
 
ronger profile image
ronger

This is very useful post for me. This will absolutely going to help me in my project. Palworld Calculator

Collapse
 
kaloo profile image
Kaloo

Neal Fun Games offers an incredibly diverse and engaging collection of interactive experiences. From quirky simulations and playful experiments to thought-provoking challenges, Neal's creations cater to a wide range of interests and ages. The unique blend of creativity, simplicity, and educational value in each game makes them not only entertaining but also enriching. Whether you're looking to pass the time with a fun distraction or delve into a more complex project, Neal Fun Games has something for everyone.

Collapse
 
ariel190293 profile image
Ariel190293

This overview of basic curl command options provides essential knowledge for web application developers. Understanding these options, such as Pokerogue adding headers with -H, making POST requests with parameters using -d, and specifying request methods with -X, is crucial for interacting with web services effectively.

Collapse
 
helenat59930026 profile image
Helena Thompson

It is said that the retro style of design will never go out of fashion and always be popular among women. It is simple but still gives an eye-catching look and people like it because they are not complicated as other holiday nail styles.

Collapse
 
tomusa0106 profile image
tomusa0106

The posts on the site are great. today is my first time on this site, krunker I am very impressed with your post. Thank you for sharing so much useful information.

Collapse
 
adamoldham profile image
AdamOldham

Mastering basic curl options is essential for web developers, much like mastering the thrilling courses in Snow Rider 3D. Familiarity with these commands enhances your efficiency, just as navigating snowy slopes hones your skills. Explore these fundamentals, and if you have more options to share, don't hesitate to comment!

Collapse
 
ren_yu_eaa17545e508a1106e profile image
ren yu

bgsi script is a specialized resource offering various scripts for Roblox's Bubble Gum Simulator INFINITY game. The site provides players with access to customized scripts designed to enhance gameplay experience. These scripts offer various functionalities to help players progress through the game more efficiently. BGSI script caters to Roblox enthusiasts looking to maximize their performance in this popular simulator. The website features a collection of regularly updated scripts, making it a valuable destination for dedicated Bubble Gum Simulator INFINITY players seeking to optimize their gaming experience and gain advantages in the virtual bubble-blowing world.

Collapse
 
kencanacars profile image
Kencana Cars

sewa mobil jogja lepas kunci naura transport. Sewa Mobil jogja, Bali, Malang, Surabaya, Semarang dan bandung Lepas Kunci Tarif Harga Termurah Dengan Syarat Mudah & Tersedia Mobil Matic Toyota Avanza FWD, Honda Brio, Mitsubishi Xpander, Toyota Agya, Honda Mobilio, Daihatsu Ayla Durasi 6, 12, 24 Jam Harian Atau Bulanan.

Collapse
 
kencanacars profile image
Kencana Cars

Sewa mobil kencana cars dengan pilihan kendaraan terbaik seperti sewa alphard semarang, Hiace, Innova, dan Fortuner. Nikmati pengalaman berkendara yang nyaman dan fleksibel dengan sewa alphard solo untuk acara istimewa atau bisnis Anda. Dapatkan juga kenyamanan dan ruang yang luas dengan sewa hiace jogja untuk perjalanan kelompok besar. Selain itu, tersedia juga layanan sewa innova jogja yang praktis dan sewa fortuner jogja yang tangguh. Temukan kendaraan yang sesuai dengan kebutuhan perjalanan Anda dengan sewa mobil jogja lepas kunci

Some comments may only be visible to logged-in visitors. Sign in to view all comments.