From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Newsgroups: gmane.lisp.guile.user Subject: Re: Questions about the (web client) module. Date: Thu, 20 Jul 2017 17:41:09 +0200 Message-ID: <878tjjru96.fsf@gnu.org> References: <87o9sfxtuk.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1500565311 7063 195.159.176.226 (20 Jul 2017 15:41:51 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 20 Jul 2017 15:41:51 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Thu Jul 20 17:41:47 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dYDaA-0001ME-2q for guile-user@m.gmane.org; Thu, 20 Jul 2017 17:41:42 +0200 Original-Received: from localhost ([::1]:38712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYDaF-00087K-OI for guile-user@m.gmane.org; Thu, 20 Jul 2017 11:41:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYDZu-00086V-8M for guile-user@gnu.org; Thu, 20 Jul 2017 11:41:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dYDZr-0003vB-2j for guile-user@gnu.org; Thu, 20 Jul 2017 11:41:26 -0400 Original-Received: from [195.159.176.226] (port=47300 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dYDZq-0003uy-ST for guile-user@gnu.org; Thu, 20 Jul 2017 11:41:23 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dYDZj-0008SU-1S for guile-user@gnu.org; Thu, 20 Jul 2017 17:41:15 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 52 Original-X-Complaints-To: usenet@blaine.gmane.org X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 2 Thermidor an 225 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-unknown-linux-gnu Cancel-Lock: sha1:egSLzrxaLw/qT59VaVeZ3QHLOi0= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13951 Archived-At: Hi Roel, Roel Janssen skribis: > When I use http-post, and I want to change the HTTP header called > "Content-Type", I seem to need to spell it as "content-type" in the > #:headers part of the 'http-post' section. Other headers like "Accept" > do not seem to follow the same lowercase style route. > > More confusingly, using something like: > #:headers '((Content-Type . "text/csv")) > > leads to outputting the "Content-Type" header twice. > Why is "content-type" special? ‘sanitize-request’ in (web client) adds a ‘Content-Type’ header if there is none. As for lower-case, perhaps the ‘request’ procedure in (web client) should automatically convert to lower-case, or perhaps we should simply clarify the documentation here. > Then my next question is about "multipart/form-data" content types. > My code looks like this: > > #:headers `((content-type . ,(string-append > "multipart/form-data; boundary=" boundary)) > (Accept . "*/*")) > > But that does not work: > scheme@(guile-user)> > web/request.scm:184:10: In procedure build-request: > web/request.scm:184:10: Bad request: Bad value for header content-type: "multipart/form-data; boundary=..." > > This is, however, a valid Content-Type. What’s the value of ‘boundary’? At first sight it looks good to me: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,use(web http) scheme@(guile-user)> (valid-header? 'content-type (parse-header 'content-type "text/plain")) $13 = #t scheme@(guile-user)> (valid-header? 'content-type (parse-header 'content-type "multipart/form-data; boundary=2")) $14 = #t scheme@(guile-user)> (valid-header? 'content-type (parse-header 'content-type "multipart/form-data; boundary=sdfd")) $15 = #t scheme@(guile-user)> (parse-header 'content-type "multipart/form-data; boundary=sdfd") $16 = (multipart/form-data (boundary . "sdfd")) --8<---------------cut here---------------end--------------->8--- HTH! Ludo’.