我正在尝试使用cUrl登录基于HTTP的强制网络门户。 一发出请求,我就会收到以下信息:
> HTTP/1.1 200 OK Location:
> Location: https://somewebsite:someport/portal/gateway?sessionId=someid&portal=someportal&action=cwa&token=sometoken
我真的想按照Location标头,但是,因为即使我使用-L选项,状态代码是200 cUrl也不遵循重定向。 (我很清楚重定向的状态代码不应该是200,但它不是我控制下的门户,所以我无法改变它。)
所以我尝试的下一件事是从响应中解析位置标头并向其查询cUrl,如下所示:
cUrl -sS -v https://somewebsite:someport/portal/gateway?sessionId=someid&portal=someportal&action=cwa&token=sometoken`
但是,这会返回以下输出(用<>屏蔽):
* Trying <someip>... [308/1885]
* Local Interface wlan0 is ip <someip> using address family 2
* Local port: 0
* Connected to <somehost> (<someip>) port <someport> (#0)
* found 173 certificates in /etc/ssl/certs/ca-certificates.crt
* found 707 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.0 / RSA_AES_128_CBC_SHA1
* server certificate verification OK
* server certificate status verification SKIPPED
* common name: <somename> (matched)
* server certificate expiration date OK
* server certificate activation date OK
* certificate public key: RSA
* certificate version: #3
* subject: <somesubject>
* start date: Thu, 13 Oct 2016 09:59:25 GMT
* expire date: Tue, 09 Jul 2019 23:59:00 GMT
* issuer: <someissuer>
* compression: NULL
* ALPN, server did not agree to a protocol
> GET <urlwithouthost> HTTP/1.1
> Host: <host>:<port>
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Set-Cookie: JSESSIONID=<notSameIdAsInUrl>; Path=/portal/; Secure; HttpOnly
< Content-Type: text/html;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Fri, 22 Sep 2017 10:00:27 GMT
< Server: server
<
...
如果有人知道为什么我经常会“找不到”,即使我只是按照重定向,我也非常感谢任何解决此问题的建议。
问候, 拉斯