2017-06-14 76 views
0

失敗如果我把下面的兩個命令Windows命令提示符中捲曲的Cookie通過Windows批處理文件

命令1:

捲曲-d用戶id =「my.name 「-d密碼=」 my.password」 https://localhost:443/test/login -X POST -c 「cookie.txt的」 -w 「%{RESPONSE_CODE}」 -k

命令2:

捲曲-F文件1 = @ 「C:\ test.zip」 https://localhost:443/test/upload -b 「cookie.txt的」 -w 「%{RESPONSE_CODE}」 -k

的Cookie通常是在接收到的第二呼叫。

如果我在Windows批處理文件中放入了相同的兩個命令,則在第二次調用中不會收到cookie。爲什麼?

更新:

這個問題似乎涉及到cookie的批處理文件中的第二個電話傳遞。捲曲的在命令提示符第二個電話(僅第二個命令,外面批處理文件)詳細的輸出是:

* Trying ::1... 
* TCP_NODELAY set 
* Connected to localhost (::1) port 443 (#0) 
* ALPN, offering h2 
* ALPN, offering http/1.1 
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH 
* TLSv1.2 (OUT), TLS handshake, Client hello (1): 
* TLSv1.2 (IN), TLS handshake, Server hello (2): 
* TLSv1.2 (IN), TLS handshake, Certificate (11): 
* TLSv1.2 (IN), TLS handshake, Server key exchange (12): 
* TLSv1.2 (IN), TLS handshake, Server finished (14): 
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16): 
* TLSv1.2 (OUT), TLS change cipher, Client hello (1): 
* TLSv1.2 (OUT), TLS handshake, Finished (20): 
* TLSv1.2 (IN), TLS handshake, Finished (20): 
* SSL connection using TLSv1.2/ECDHE-RSA-AES256-GCM-SHA384 
* ALPN, server accepted to use h2 
* Server certificate: 
* subject: CN=localhost 
* start date: May 31 14:47:57 2017 GMT 
* expire date: May 31 00:00:00 2022 GMT 
* issuer: CN=localhost 
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway. 
* Using HTTP2, server supports multi-use 
* Connection state changed (HTTP/2 confirmed) 
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 
* Using Stream ID: 1 (easy handle 0x1c3ff9650f0) 
> POST /test/upload HTTP/2 
> Host: localhost:443 
> User-Agent: curl/7.54.0 
> Accept: */* 
> Cookie: .AspNetCore.Password=VfDJ8DTHwtekoe5CixP71DROzvv-mAa0MfVBtNW71ESzGLMJ6txx48wVZU_w6nBczSP681tzYTUHLsgGVuvo2lx6pwTO-WJhpDvUcSxsUWKNurEqgZBRBo0RxLK4ubHCcncNnAbVCsc_McoKcEHFqy-cFvztqEDtNPlG7UTmI2685tfzM_W7csgUIOL9nfbo3T4cCytJXBfqCSrHRBkNN_wDD6QhDOpuiBKdy5cVhN4pXA2zh4WyCtOmrVHrJDwDDTdJEZMj7j59Y1AGT1diV8QivU2DuMcwbMrT7y3TmFRwhw5j30wukAV95MYw4357_87SX4XY9WwAJdncL0fMJ3OznVTVC9rUI3Tvi8M6KKfV3Lkb 
> Content-Length: 735 
> Content-Type: multipart/form-data; boundary=------------------------8ecfb7321f78c8b5 
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)! 
< HTTP/2 202 
< cache-control: no-cache 
< pragma: no-cache 
< expires: -1 
< server: Kestrel 
* Replaced cookie .AspNetCore.Password="" for domain localhost, path /test, expire 1 
< set-cookie: .AspNetCore.Password=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/test 
< x-sourcefiles: =?UTF-8?B?RDpcUHJvamVjdHNcVmV0Q29tcGFzc1xjb2RlXGFzcFxWZXRDb21wYXNzLlVJXHNyY1xWZXRDb21wYXNzLlVJXGFwaVxkYXRhdXBsb2FkXHVwbG9hZA==?= 
< x-powered-by: ASP.NET 
< date: Wed, 14 Jun 2017 13:46:28 GMT 
< content-length: 0 
< 
* Connection #0 to host localhost left intact 
202 

批處理文件(第二個命令只,相同的指令)的詳細輸出是內部:

* Rebuilt URL to: ÔÇôb/ 
* Failed to convert ÔÇôb to ACE; 
* Could not resolve host: ÔÇôb 
* Closing connection 0 
000curl: (6) Could not resolve host: ÔÇôb 
* Rebuilt URL to: cookies.txt/ 
* Trying 81.200.64.50... 
* TCP_NODELAY set 
* Connected to cookies.txt (81.200.64.50) port 80 (#1) 
> POST/HTTP/1.1 
> Host: cookies.txt 
> User-Agent: curl/7.54.0 
> Accept: */* 
> Content-Length: 735 
> Expect: 100-continue 
> Content-Type: multipart/form-data; boundary=------------------------5fb5c68be6042795 
> 
* Empty reply from server 
* Connection #1 to host cookies.txt left intact 
000curl: (52) Empty reply from server 
* Trying ::1... 
* TCP_NODELAY set 
* Connected to localhost (::1) port 443 (#2) 
* ALPN, offering h2 
* ALPN, offering http/1.1 
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH 
* TLSv1.2 (OUT), TLS handshake, Client hello (1): 
* TLSv1.2 (IN), TLS handshake, Server hello (2): 
* TLSv1.2 (IN), TLS handshake, Certificate (11): 
* TLSv1.2 (IN), TLS handshake, Server key exchange (12): 
* TLSv1.2 (IN), TLS handshake, Server finished (14): 
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16): 
* TLSv1.2 (OUT), TLS change cipher, Client hello (1): 
* TLSv1.2 (OUT), TLS handshake, Finished (20): 
* TLSv1.2 (IN), TLS handshake, Finished (20): 
* SSL connection using TLSv1.2/ECDHE-RSA-AES256-GCM-SHA384 
* ALPN, server accepted to use h2 
* Server certificate: 
* subject: CN=localhost 
* start date: May 31 14:47:57 2017 GMT 
* expire date: May 31 00:00:00 2022 GMT 
* issuer: CN=localhost 
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway. 
* Using HTTP2, server supports multi-use 
* Connection state changed (HTTP/2 confirmed) 
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 
* Using Stream ID: 1 (easy handle 0x1fda6c350f0) 
> POST /test/upload HTTP/2 
> Host: localhost:443 
> User-Agent: curl/7.54.0 
> Accept: */* 
> Content-Length: 735 
> Content-Type: multipart/form-data; boundary=------------------------bf4df70798c79cba 
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)! 
< HTTP/2 502 
< cache-control: private 
< content-type: text/html; charset=utf-8 
< server: Microsoft-IIS/10.0 
< x-sourcefiles: =?UTF-8?B?RDpcUHJvamVjdHNcVmV0Q29tcGFzc1xjb2RlXGFzcFxWZXRDb21wYXNzLlVJXHNyY1xWZXRDb21wYXNzLlVJXGFwaVxkYXRhdXBsb2FkXHVwbG9hZA==?= 
< x-powered-by: ASP.NET 
< date: Wed, 14 Jun 2017 13:52:09 GMT 
< content-length: 4963 
* Connection #2 to host localhost left intact 
502 

只要我刪除-b "cookies.txt"Rebuilt URL to: ÔÇôb/輸出就會消失。

+0

嘗試加倍所有'%'百分號。 '... -w「%% {response_code}」' – jeb

+0

謝謝@jeb。已經這樣做了。在第二次調用中添加-b cookies.txt後,批處理文件中的CURL會做一些奇怪的事情 – Marlau

回答

0

該問題與批處理文件的編碼有關。非常尷尬,我沒有檢查過這個。我沒有意識到這個文件不是ANSI編碼的。有一個UTF-8字符看起來像連字符。轉換爲ANSI編碼後,該字符顯示出來。