2017-06-14 2 views
0

über Windows-Batch-Datei gesendet Wenn ich Aufforderung die folgenden zwei Befehle innerhalb eines Windows-Befehls sendenROTATION Plätzchen erfolgreich über Windows-Eingabeaufforderung nicht

Befehl 1:

curl -d userId = "my.name "-d password =" my.password“ https://localhost:443/test/login -X POST -c "cookies.txt" -w "% {RESPONSE_CODE}" -k

Command 2:

curl -F file1 = @ "C: \ test.zip" https://localhost:443/test/upload -B "cookies.txt" -w "% {RESPONSE_CODE}" -k

die Cookies in der zweiten empfangenen Anruf.

Wenn ich dieselben zwei Befehle in eine Windows-Stapeldatei einfüge, werden die Cookies beim zweiten Aufruf nicht empfangen. Warum?

Update:

Das Problem scheint im Laufe des Cookies in dem zweiten Aufruf in der Batch-Datei bezogen werden. Curls ausführliche Ausgabe für den zweiten Anruf in der Eingabeaufforderung (2. Befehl nur außerhalb Batch-Datei) ist:

* 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 

Innerhalb der Batch-Datei (2. Befehl nur, exakt gleicher Befehl) die ausführliche Ausgabe ist:

* 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 

Sobald ich -b "cookies.txt" entferne, geht der Rebuilt URL to: ÔÇôb/ Ausgang weg.

+0

Versuchen Sie, alle '%' Prozentzeichen zu verdoppeln. '... -w" %% {response_code} "' – jeb

+0

danke @jeb. Das schon tun. CURL in der Batchdatei macht etwas seltsames, sobald dem zweiten Aufruf '-b cookies.txt' hinzugefügt wird – Marlau

Antwort

0

Das Problem bezog sich auf die Codierung der Stapeldatei. Sehr peinlich, dass ich das vorher nicht überprüft habe. Ich wusste nicht, dass die Datei nicht ANSI-kodiert war. Es gab ein UTF-8-Zeichen, das wie ein Bindestrich aussah. Nach der Umwandlung in die ANSI-Codierung zeigte sich das Zeichen selbst.