Posted in LearningItMyWay

cURL

We were trying to test our new Node.js app. I was building a REST API and it worked fine with JSON input. I used POSTMAN (which I heard just a week ago from my colleague Shiv). I must tell you, it is really great. POSTMAN could have been a new topic under #LearningItMyWay. But anyways, it has got a mention here.

When our Front End Engineer Sanjeet tried calling my REST API through JQuery AJAX, we kept getting CORS (cross origin resource sharing) errors. This part is yet to be resolved, and I shall blog on it soon (Insha Allah). Read More

Shiv came and tested using curl on PHP. This wasn’t the first time I had heard about curl, but I had never used it earlier. So this becomes a good topic for #LearningItMyWay.

“curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work without user interaction.

curl offers a busload of useful tricks like proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer resume, Metalink, and more.”
(from this link)

So, basically, cURL is a command line tool for getting or sending files using URL syntax. curl url

There are various options for this command, but I haven’t bothered to know all of them for now. I only tried finding about this -L option. curl -L url

The -L option, allows to follow redirects with curl.

In my REST API written using Express on Node.js, I was using passport module for authentication. Passport does appropriate redirects based on login success or failure. When Shiv tested this API using curl, the redirects weren’t working as expected, and for once we were trying to find if Express redirects were working fine or not. Later, I found about this -L option for curl, and that was #LearningItMyWay.

Blogging has been fun so far, happy two days of blogging for me 🙂

Advertisements

Author:

Technology and start-up enthusiast. JavaScript is my second love, food comes first ;). Love coding, attending technical conferences, learning new things and meeting new people.

2 thoughts on “cURL

  1. Pingback: CORS | princiya777
  2. Almost every programming language has a curl module .. which is what makes it so awesome. It is a great way to call POST APIs from your server side application.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s