Curl test your http server

Web

Basic usage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# get /index
curl http://localhost

# Post data
curl -d "param1=value1&param2=value2" -X POST http://localhost/data

# Post file
curl -d "@data.txt" -X POST http://localhost/data

# -H set header
curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST http://localhost/data

# When you got error, try http1.1
# curl: (92) HTTP/2 stream 1 was not closed cleanly: REFUSED_STREAM (err 7)
curl --http1.1 http://localhost

# When you got this, try -k
# curl: (60) SSL certificate problem: self signed certificate
curl -k https://localhost

# login
curl --http1.1 -k -d '{"username":"abc@abc.com","password":"123456","role":"user","type":"json"}' -X POST -H "Content-Type: application/json" https://localhost/auth

Reference

https://gist.github.com/subfuzion/08c5d85437d5d4f00e58