From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: wolf Newsgroups: gmane.lisp.guile.user Subject: Re: extract headers from response record Date: Thu, 10 Aug 2023 00:34:22 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="hc3pAB3SGI74/w+L" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16490"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user@gnu.org To: Mortimer Cladwell Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Thu Aug 10 00:35:08 2023 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qTrlj-00043U-W8 for guile-user@m.gmane-mx.org; Thu, 10 Aug 2023 00:35:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTrl9-0006of-Dx; Wed, 09 Aug 2023 18:34:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qTrl7-0006oJ-79 for guile-user@gnu.org; Wed, 09 Aug 2023 18:34:29 -0400 Original-Received: from wolfsden.cz ([37.205.8.62]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qTrl4-0006Vo-Tf for guile-user@gnu.org; Wed, 09 Aug 2023 18:34:29 -0400 Original-Received: by wolfsden.cz (Postfix, from userid 104) id 68E4E26DFE8; Wed, 9 Aug 2023 22:34:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1691620463; bh=SI3O267d3aJN00RIlcKal008spfkHEhWs1tmoRdIaDc=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Q+K4DmwyrduL2XUPbcsCjzrUmNtwmWBVr8JMc2vZJ7k5Wjf3hJ16xx+DaMDlhW7ey uEFGeMZ7wKG7ZT0NYind1wtT6sh90HZiXGTS65xGNGezEJ+9PAK4K8F52RCVTm9R17 s9sb1uFcxxP4iowCwG+HR2Sn4v0rq86oXK4MoHUhsBZhXZlkspTxFkuQMT+LAYW6yE qOuT9e8Q8h/vYPs1hbnJDGcRRdRMuOyQQ6ofrKgPdx3ACSOY8TwVcIvPWz/WXGoaN4 EhkChrdNgFuJuWloP6jrY7C5ISQOkdAYgepj44LFHDqJydquw+olT5KWEVL/7Alu8f X55EBGK90tozMg4xGnaEgUy+IkY+mBhKZ0rGySV7oKlfwWood0cbmLhLR4/KudzsAa U7wsjLoEljG2jfemwFDnfV4t2hoxOPXv0i6R8CGSjlL/4jxLGAdWzPUDqwuxaeKFmz KdFOgV9TULiHHBCB3pDzJUAyz9EisFdqnnlf7V1P/IRZzk/bx/TsrsW6/PqVfPC2w6 GQvzxvsT/ldc0M35buHUmTbk92S7L70EhFkHv5dwuVAYHRkpD7gZAEfYtEJ1W+HxsL HOhPwJOrIxkZXYzFqHjgo3EMH3PpYLqmbIJgmyb0T5Pf1itXwDB51It0MD15W2Kp3G IMd0EeJt/oiNhovVb+WTsCF4= Original-Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id E59FA26C6DB; Wed, 9 Aug 2023 22:34:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1691620462; bh=SI3O267d3aJN00RIlcKal008spfkHEhWs1tmoRdIaDc=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=SW9qTchHg6/0LtDzTTMPuTonAEwTIv9r2vWBZf8GKsaOcjIfiQ8G3JUPP/vqMpfp9 +c7BloKLSey4i8JsYGzy7P6nU1WCQ5P6rsV4PJMDYWAmMRQgokQGFTLcuMHxx2xQlO NlLyvjdYB3uyCbFu3a/X0D0sMMbJHd0lGLI9kvpEXKMrB3iZGuLypN/h4j1zCKsB3q 5u8yTwyIvUWWNZgbChoCahr6sEch+KmV9NQufIJ7ZlhKRmc3xRZIWXxZWoFa3xIHBV i/4KBbboih1VV+zjWeW+gb85kl92imVmhJw2H+9SdZXmRwdz3JC5FK9EbKSkeQ5gs/ NS5sgx+bMVmsjvfKlebtBXnPx0+K9e+ehkuyTauX0+k5EJ8ZC3lEe8g+MXDAANObyU j7uA2KuaGFsA48HHvOmDGP5T7+Rjnq7tZHeITqk+yE+2gEYH02uteD1yDra43yHYCx 1hG7AFM4ech9T8FMUE5bGzYhpzgRZV0WQouvMb/BGVhapuhSBMPXSDNgKVXOqe0X+b XsZBvle5ME4v3H0Ah1Zs6JYJWgz2SdjREw2Ytk0Q9/Djn+hcaFAXU0TF7rgkUCRdfd rTAEPmUgiqMSUfHmWhaj7D4Iftx+K1JJIao9SJunSkcLaWUH/6JpuKpyNlIJYH//7B W/RLxQwRGFcUZiAdF5qV+Jfw= Original-Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 57d4d737; Wed, 9 Aug 2023 22:34:22 +0000 (UTC) Mail-Followup-To: Mortimer Cladwell , guile-user@gnu.org Content-Disposition: inline In-Reply-To: Received-SPF: none client-ip=37.205.8.62; envelope-from=ws@wolfsnet.cz; helo=wolfsden.cz X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_PASS=-0.001, SPF_NONE=0.001, UNPARSEABLE_RELAY=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:19140 Archived-At: --hc3pAB3SGI74/w+L Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2023-08-09 10:18:05 -0400, Mortimer Cladwell wrote: > Hi, > I am running a local fake Urbit zod on port 8080. I want to submit an > http-request and obtain an urbauth id cookie. I run the following method: >=20 > (use-modules (web client)(web response) (srfi srfi-9)(oop goops) (ice-9 > receive) (ice-9 pretty-print)) >=20 > (define (urbit-http-connect) > (let* ((uri "http://localhost:8080/~/login") > (data (string-append "password=3D" "lidlut-tabwed-pillex-ridrup"= )) > (a (receive (response body) > (http-request uri #:method 'POST #:body data) > response))) > (pretty-print a))) >=20 > =3D=3D> #< version: (1 . 1) code: 204 reason-phrase: "ok" heade= rs: > ((date . # 8 year: 2023 zone-offset: 0>) (connection close) (server . > "urbit/vere-2.11") (set-cookie . > "urbauth-~zod=3D0v7.126dd.8rbvk.lga05.jvieb.287to; Path=3D/; Max-Age=3D60= 4800")) > port: #> >=20 > Below I substitute (pretty-print a) with various commands and show the > response: >=20 > (pretty-print (class-of a)) =3D=3D> #< <> 7f721fc4c280> > (pretty-print (record? a)) =3D=3D> #t > (pretty-print (response? a)) =3D=3D> #f >=20 > (pretty-print (response-headers a)) =3D=3D> In procedure response-header= s: > Wrong type argument: #< version: (1 . 1) code: 204 reason-phras= e: > "ok" headers: ((date . # day: 9 month: 8 year: 2023 zone-offset: 0>) (connection close) (server . > "urbit/vere-2.11") (set-cookie . > "urbauth-~zod=3D0v5.9pm4c.pa0qd.00hao.vsq1p.h37hh; Path=3D/; Max-Age=3D60= 4800")) > port: #> >=20 > So I have a record that looks like a record but isn't. How do I > extract the headers from this 'response'? I apologize for my previous message, apparently my reading comprehension is really low at this time of day. Anyway, to actually answer the question: response-headers is the procedure you are looking for. You are already usi= ng it, and it works for me (without the receive, so maybe consider dropping it since it is not necessary): ((accept-ranges bytes) (cache-control (max-age . 604800)) (content-type text/html (charset . "UTF-8")) (date . #) (etag "3147526947" . #t) (expires . #) (last-modified . #) (server . "EOS (vny/044F)") (content-length . 1256) (connection close)) Expression evaluated was: (use-modules (ice-9 pretty-print) (ice-9 receive) (web client) (web response)) (define (urbit-http-connect) (let* ((uri "http://example.org") (data (string-append "password=3D" "lidlut-tabwed-pillex-ridrup")) (response (http-request uri #:method 'POST #:body data))) (pretty-print (response-headers response)))) (urbit-http-connect) > How do I determine the record type? > Thanks > Mortimer W. --=20 There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors. --hc3pAB3SGI74/w+L Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmTUFG4ACgkQL7/ufbZ/ walD+w//RJQYEt+bUEjR+B8DWCKqySUiredYmLxydp1xDnRCpjxAblFSOmXoLYor RaQEOtZEwap8bEtwQqgoJXHFO8SC17l88jR412ngbLarDsZsIAX8GFlr8is2iJAU ON6F4vQFEz2HuyAj7OhL5xA+NwZ8i+gzHR3/nMAf+0nH3tdmx1xeQOmqswv+uZBz 7jriIcGMVZlHImGKkpv0AeAENDMl52j0mxlr63C8Zrviptd0jN1tYtfso/hzaZNI MvW0clLXWvkCVPrCtMKXqu3QBdYsDoBZsrYiZTQc21uEaoYSZJC8P+ItYwjqxc3a TskvAxHCLri36gWq2+fC+fZcFVX3WF7Bj92d1aU5vSyHhz86odwwuDVl+VSin1OA YXpM9NJ3dfZ8W4vxrxzGKpOoEFbSCF76N9JDsBpbZqN7movXo2kklf/mFHbxd5KR MBq6cUA6+LKl80A/r+1sBAwV1CIC1cqidRFQY70mNtgUmvLeYVNgBTcOFuuyrqko OS5X3+e+PG1Z22Wehf3xeXcwBfUKIJk3kDoF7mu7/L0mz79lspRwDzSiHKqNJCdF ShzVJuwWRLXwtSLzJJ9KH0dAO8WEaEiLMevfUSoGRUsxZgtD7rB+uF/khJonC5Q/ upfgyZl/gCpKnmUhO3/Tl8X3m+Vocf0Kdd8JkgCgQZ0WtRD0x00= =rO7T -----END PGP SIGNATURE----- --hc3pAB3SGI74/w+L--