使用curl命令测试在cmd和Power shell 出问题了
Topic sourceC:\Users\admin>curl http://localhost:8080/upload/file -v -d 'test-data' \
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> POST /upload/file HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.55.1
> Accept: */*
> Content-Length: 11
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 11 out of 11 bytes
< HTTP/1.1 400
< Transfer-Encoding: chunked
< Date: Fri, 09 Oct 2020 06:53:54 GMT
< Connection: close
<
<html><body><h1>Missing signature.</h1></body></html>* Closing connection 0
* Rebuilt URL to: \/
* Could not resolve host: \
* Closing connection 1
curl: (6) Could not resolve host: \
C:\Users\admin> -H 'Signature-Method: SHA-1' \
'-H' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
C:\Users\admin> -H 'Signature: 7115e9890f5b5cc6914bdfa3b7c011db1cdafedb' \
'-H' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
powershell
PS C:\Users\admin> curl http://localhost:8080/upload/file -v -d 'test-data' \
>> -H 'Signature-Method: SHA-1' \
>> -H 'Signature: 7115e9890f5b5cc6914bdfa3b7c011db1cdafedb' \
>> -H 'Content-Type: application/octet-stream'
Invoke-WebRequest : 找不到接受实际参数“test-data”的位置形式参数。
所在位置 行:1 字符: 1
+ curl http://localhost:8080/upload/file -v -d 'test-data' \
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest],ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
-H : 无法将“-H”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然
后再试一次。
所在位置 行:2 字符: 3
+ -H 'Signature-Method: SHA-1' \
+ ~~
+ CategoryInfo : ObjectNotFound: (-H:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-H : 无法将“-H”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然
后再试一次。
所在位置 行:3 字符: 3
+ -H 'Signature: 7115e9890f5b5cc6914bdfa3b7c011db1cdafedb' \
+ ~~
+ CategoryInfo : ObjectNotFound: (-H:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-H : 无法将“-H”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然
后再试一次。
所在位置 行:4 字符: 3
+ -H 'Content-Type: application/octet-stream'
+ ~~
+ CategoryInfo : ObjectNotFound: (-H:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
power shell 暂时没搞懂语法,cmd已经测试修改成功了,下面是运行截图,首先就是单引号要改成双引号,否则会识别出错,而后是Signature需要自己额外计算下,廖大佬的和我自己编码计算出来的并不一样(笑哭)
成功版:
C:\Users\wyxgoishin>curl http://localhost:8080/LearnWeb/upload/file -v -d "test.data" -H "Signature-Method: SHA-1" -H "Signature: 6019314efdb47f11e28d305081f194b3fd3d1e90" -H "Content-Type: application/octet-stream"
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> POST /LearnWeb/upload/file HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.55.1
> Accept: */*
> Signature-Method: SHA-1
> Signature: 6019314efdb47f11e28d305081f194b3fd3d1e90
> Content-Type: application/octet-stream
> Content-Length: 9
>
* upload completely sent off: 9 out of 9 bytes
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Transfer-Encoding: chunked
< Date: Fri, 30 Oct 2020 12:11:09 GMT
<
<h1>Uploaded:</h1><pre><code></code></pre>* Connection #0 to host localhost left intact
直接复制版:
C:\Users\wyxgoishin>curl http://localhost:8080/LearnWeb/upload/file -v -d 'test-data' -H 'Signature-Method: SHA-1' -H 'Signature: 7115e9890f5b5cc6914bdfa3b7c011db1cdafedb' -H 'Content-Type: application/octet-stream'
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> POST /LearnWeb/upload/file HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.55.1
> Accept: */*
> Content-Length: 11
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 11 out of 11 bytes
< HTTP/1.1 400 Bad Request
< Server: Apache-Coyote/1.1
< Transfer-Encoding: chunked
< Date: Fri, 30 Oct 2020 11:58:07 GMT
< Connection: close
<
<html><body><h1>Missing signature.</h1></body></html>* Closing connection 0
* Rebuilt URL to: SHA-1'/
* Could not resolve host: SHA-1'
* Closing connection 1
curl: (6) Could not resolve host: SHA-1'
* Rebuilt URL to: 7115e9890f5b5cc6914bdfa3b7c011db1cdafedb'/
* Could not resolve host: 7115e9890f5b5cc6914bdfa3b7c011db1cdafedb'
* Closing connection 2
curl: (6) Could not resolve host: 7115e9890f5b5cc6914bdfa3b7c011db1cdafedb'
* Could not resolve host: application
* Closing connection 3
curl: (6) Could not resolve host: application
- 1
用户5273497715
cmd