What is the scene of commonly used curl commands?
What the commonly used curl command scenarios are, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.
Curl is a command on linux that can send http requests. Of course, Postman is a good interface call management tool, but in the case of verifying the availability of one linux server calling another linux server API, it is the curl command.
The following is mainly to introduce the commonly used curl command scenarios, you can accumulate some operation and maintenance knowledge and apply it in daily development work.
Open a website curl www.mynamecoder.com to send a POST request curl-d "userName=xiaoming&password=coder1024" http://www.mynamecoder.com/login parameter description-d: specify the passed parameter
After using the-d parameter, the HTTP request automatically adds the request header Content-Type: application/x-www-form-urlencoded. And the request is automatically converted to the POST method.
Send GET request curl-G "title=curl" http://www.mynamecoder.com/search parameter description-G: indicates get request Default is post request to send POST request in JSON format $curl-d'{"userName": "xiaoming", "password": "123456"}'- H 'Content-Type: application/json' https://www.mynamecoder.com/login parameter description-H: indicates that the HTTP request header upload file curl-F' file=@head.png' https://mynamecoder.com/upload parameter description
The above command adds the header Content-Type: multipart/form-data to the HTTP request and then uploads the file photo.png as a file field.
The-F parameter can specify the MIME type.
Curl-F 'file=@photo.png;type=image/png' https://mynamecoder.com/upload
The above command specifies that the MIME type is image/png, otherwise curl will set the MIME type to application/octet-stream by default.
The-F parameter can also specify a file name.
$curl-F 'file=@photo.png;filename=me.png' https://mynamecoder.com/upload
In the above command, the original file name is photo.png, but the file received by the server is called me.png.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.