From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.user Subject: Re: Questions about the (web client) module. Date: Fri, 21 Jul 2017 00:49:36 -0400 Message-ID: <87fudqcs2n.fsf@netris.org> References: <87o9sfxtuk.fsf@gnu.org> <878tjjru96.fsf@gnu.org> <87h8y691nm.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1500612613 12820 195.159.176.226 (21 Jul 2017 04:50:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 21 Jul 2017 04:50:13 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , guile-user@gnu.org To: Roel Janssen Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Jul 21 06:50:10 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 1dYPtB-000341-K8 for guile-user@m.gmane.org; Fri, 21 Jul 2017 06:50:09 +0200 Original-Received: from localhost ([::1]:41023 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYPtG-0007ya-Ur for guile-user@m.gmane.org; Fri, 21 Jul 2017 00:50:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYPsu-0007yD-3Z for guile-user@gnu.org; Fri, 21 Jul 2017 00:49:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dYPsq-0001Qd-W6 for guile-user@gnu.org; Fri, 21 Jul 2017 00:49:52 -0400 Original-Received: from world.peace.net ([50.252.239.5]:57682) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dYPsq-0001QO-RC; Fri, 21 Jul 2017 00:49:48 -0400 Original-Received: from pool-72-93-34-106.bstnma.east.verizon.net ([72.93.34.106] helo=jojen) by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dYPsp-00072D-EG; Fri, 21 Jul 2017 00:49:47 -0400 In-Reply-To: <87h8y691nm.fsf@gnu.org> (Roel Janssen's message of "Fri, 21 Jul 2017 00:36:13 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 50.252.239.5 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:13959 Archived-At: Roel Janssen writes: >>> 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=3D" boun= dary)) >>> (Accept . "*/*")) >>> >>> But that does not work: >>> scheme@(guile-user)>=20 >>> web/request.scm:184:10: In procedure build-request: >>> web/request.scm:184:10: Bad request: Bad value for header content-typ= e: "multipart/form-data; boundary=3D..." >>> >>> This is, however, a valid Content-Type. >> >> What=E2=80=99s the value of =E2=80=98boundary=E2=80=99? At first sight = it looks good to me: > > The value I use is "guile-virtuoso-driver". All of the below > functions work as expected with this value. > > Could it be that something else is wrong? > Here's the entire code I use: > > (define* (sparql-query-post query > #:key > (host "localhost") > (port 8890) > (graph "") > (type "json")) > (let ((base-uri (string-append "http://" host ":" (number->string port)= )) > (boundary "guile-virtuoso-driver")) > (let ((body (string-append > (format #f > "--~a~%Content-Disposition: form-data; name=3D~s~%~%tex= t/csv~%" > boundary "format") > (format #f > "--~a~%Content-Disposition: form-data; name=3D~s~%~%~a~= %--~a~%" > boundary "query" query boundary)))) > (http-post > (string-append base-uri "/sparql") > #:body body > #:headers `((content-length . ,(string-length body)) > (content-type . "multipart/form-data; boundary=3Dguile= -virtuoso-driver") The line above should be replaced with this: (content-type . (multipart/form-data (boundary . ,boundary))) > (Accept . "*/*")))))) and this should be: (accept . ((*/*))) These are the "parsed" form of HTTP headers, where the header names are lowercase symbols and the associated values are not usually strings but rather a Scheme representation of the value. See section 7.3.4 (HTTP Headers) in the Guile manual for more information. Mark