Saya menggunakan Mac 10.9.5 dengan bash shell. Saya mencoba mengirimkan permintaan melalui ikal, tetapi saya terus mendapatkan kesalahan ketika saya mencoba dan mengatur header tipe konten. Di bawah ini saya coba
davea$ curl -v -o -H "Content-Type: application/json" -X POST -d '{"username”:”username”,”password”:”password”}’ http://localhost:8080/myproject/login
tapi curl mengembalikan "curl: (6)" error "Tipe Konten" "host. Di bawah ini adalah output lengkap:
* getaddrinfo(3) failed for Content-Type:80
* Couldn't resolve host 'Content-Type'
* Closing connection 0
curl: (6) Couldn't resolve host 'Content-Type'
* Trying ::1...
* Connected to localhost (::1) port 8080 (#1)
> POST /myproject/login HTTP/1.1
> User-Agent: curl/7.40.0
> Host: localhost:8080
> Accept: */*
> Content-Length: 40
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 40 out of 40 bytes
< HTTP/1.1 302 Found
< Server: Apache-Coyote/1.1
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< Set-Cookie: JSESSIONID=B980765C84EA5759F743D1AAE8E189D0; Path=/myproject/; HttpOnly
< Location: http://localhost:8080/myproject/login?error
< Content-Length: 0
< Date: Mon, 06 Jul 2015 16:03:37 GMT
<
* Connection #1 to host localhost left intact
Apa cara yang benar untuk mengirimkan header tipe konten melalui curl?
-v
dan-o
tidak bisa digunakan bersama; jika Anda ingin output digunakan file-o
; jika Anda ingin-v
output erbose gunakan redirection file (> output.txt
)