2017-12-13 4 views
0

이 예제를 보자컬은 폼을 보낼 때 Content-Type에 덧붙입니다. 이것을 무시하는 방법은 무엇입니까?

curl http://host.compute-1.amazonaws.com:8080/oauth2/token -H "Content-Type: application/x-www-form-urlencoded" -F 'grant_type=password' -F 'username=test-user' -F 'password=password' -F 'client_id=test_application_client_id' -F 'client_secret=password' -v 

하나는 Content-Typeapplication/x-www-form-urlencoded로 설정 될 것이라고 생각합니다. 대신 Curl이 전송 application/x-www-form-urlencoded; boundary=------------------------5f55da42226c00e5

이 아닌 방법은입니까? 컬 맨 페이지에서

[email protected] ~/ $ curl http://something.compute-1.amazonaws.com:8080/oauth2/token -H "Content-Type: application/x-www-form-urlencoded" -F 'grant_type=password' -F 'username=test-user' -F 'password=password' -F 'client_id=test_application_client_id' -F 'client_secret=password' -v 
* Trying 0.0.0.0... 
* TCP_NODELAY set 
* Connected to something.compute-1.amazonaws.com (0.0.0.0) port 8080 (#0) 
> POST /oauth2/token HTTP/1.1 
> Host: something.compute-1.amazonaws.com:8080 
> User-Agent: curl/7.54.0 
> Accept: */* 
> Content-Length: 598 
> Expect: 100-continue 
> Content-Type: application/x-www-form-urlencoded; boundary=------------------------5f55da42226c00e5 
> 
< HTTP/1.1 100 Continue 
< HTTP/1.1 400 Bad Request 
< Server: Apache-Coyote/1.1 
< Date: Wed, 13 Dec 2017 00:43:13 GMT 
< Content-Type: text/plain 
< Content-Length: 145 
< Connection: close 
< 
* Closing connection 0 
WebApplicationException has been caught, status: 400, message: The Content-Type header is missing on this request you should define: Content-Type 

답변

1

:

-F, --form (HTTP)이 컬 에뮬레이트 할 수있는 채워진 사용자가 제출 버튼을 눌렀습니다있는 형태. 이

당신이 -d-F를 교체 해봤이 등 바이너리 파일을 업로드 할 수 RFC 2388. 에 따라 콘텐츠 형식의 다중/폼 데이터를 사용하여 데이터를 게시하는 컬의 원인은?

-F으로 :

$ curl -F "param1=value1&param2=value2" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://google.com -v 
* About to connect() to google.com port 80 (#0) 
* Trying 2a00:1450:400a:807::200e... 
* Connected to google.com (2a00:1450:400a:807::200e) port 80 (#0) 
> POST/HTTP/1.1 
> User-Agent: curl/7.29.0 
> Host: google.com 
> Accept: */* 
> Content-Length: 161 
> Expect: 100-continue 
> Content-Type: application/x-www-form-urlencoded; boundary=----------------------------5bb04ed0c4fe 
> 

-d으로 :

$ curl -d "param1=value1&param2=value2" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://google.com -v 
* About to connect() to google.com port 80 (#0) 
* Trying 2a00:1450:400a:807::200e... 
* Connected to google.com (2a00:1450:400a:807::200e) port 80 (#0) 
> POST/HTTP/1.1 
> User-Agent: curl/7.29.0 
> Host: google.com 
> Accept: */* 
> Content-Type: application/x-www-form-urlencoded 
> Content-Length: 27 
> 
다음

내가 모두 얻을 것입니다

관련 문제