0

我正在尝试使用 cUrl 登录基于 HTTP 的强制门户。一旦我发送请求,我就会得到以下回复:

> HTTP/1.1 200 OK Location:
> Location: https://somewebsite:someport/portal/gateway?sessionId=someid&portal=someportal&action=cwa&token=sometoken

但是,我真的很想关注 Location 标头,因为状态代码是 200,即使我使用 -L 选项,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
< 
...

如果有人知道为什么我经常得到“找不到”,即使我只是按照重定向,我真的很感激任何解决这个问题的建议。

问候,拉斯

4

0 回答 0