gpt4 book ai didi

https - 使用 Racket 连接到 HTTPS 服务器

转载 作者:行者123 更新时间:2023-12-05 00:21:26 26 4
gpt4 key购买 nike

当我尝试使用 Racket 的 net/http-client 通过 HTTPS 连接到网络服务器时包,发生以下情况:

#t

➜  code  racket                
Welcome to Racket v6.2.
> (require net/http-client)
> (http-sendrecv "google.com" "/" #:ssl? #t)
ssl-connect: requested protocol not supported
requested: 'auto
context...:
/usr/local/share/racket/collects/openssl/mzssl.rkt:608:0: make-raw-context
/usr/local/share/racket/collects/openssl/mzssl.rkt:482:18
/usr/local/share/racket/collects/racket/private/more-scheme.rkt:264:2: call-with-exception-handler
/usr/local/share/racket/collects/net/http-client.rkt:294:0: http-sendrecv92
/usr/local/share/racket/collects/racket/private/misc.rkt:87:7

'tls
> (require net/http-client)
> (http-sendrecv "google.com" "/" #:ssl? 'tls)
ssl-connect: requested protocol not supported
requested: 'tls
context...:
/usr/local/share/racket/collects/openssl/mzssl.rkt:608:0: make-raw-context
/usr/local/share/racket/collects/openssl/mzssl.rkt:482:18
/usr/local/share/racket/collects/racket/private/more-scheme.rkt:264:2: call-with-exception-handler
/usr/local/share/racket/collects/net/http-client.rkt:294:0: http-sendrecv92
/usr/local/share/racket/collects/racket/private/misc.rkt:87:7
(supported-client-protocols) 的输出
> (require openssl)
> (supported-client-protocols)
'()

我如何使用 http-sendrecv连接到 HTTPS 服务器?

最佳答案

使用 'tls而不是 #t .

> (require net/http-client)
> (http-sendrecv "google.com" "/" #:ssl? 'tls)
#"HTTP/1.1 302 Found"
'(#"Location: https://www.google.dk/?gws_rd=cr&ei=10q1Ve3dMsm4sQGd_KioAQ"
#"Cache-Control: private"
#"Content-Type: text/html; charset=UTF-8"
#"P3P: CP=\"This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info.\""
#"Date: Sun, 26 Jul 2015 21:02:15 GMT"
#"Server: gws"
#"Content-Length: 259"
#"X-XSS-Protection: 1; mode=block"
#"X-Frame-Options: SAMEORIGIN"
#"Set-Cookie: PREF=ID=1111111111111111:FF=0:TM=1437944535:LM=1437944535:V=1:S=_FmpeZRsEpdAXW_-; expires=Tue, 25-Jul-2017 21:02:15 GMT; path=/; domain=.google.com"
#"Set-Cookie: NID=69=GDETUcLzNFvaXS9uD9fxW_rA-k3ywu9vsb8VVCBUUOrbL-BmWjxpj0duYXoNZyH0EHMt54dmVnn3xPJvESfM4tLy_T8DYCsas_9dloNB9s6NfcxmbeD4DQzAAou0ly_l; expires=Mon, 25-Jan-2016 21:02:15 GMT; path=/; domain=.google.com; HttpOnly"
#"Connection: close")
#<input-port:pipe>

关于https - 使用 Racket 连接到 HTTPS 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31641819/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com