From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Price Newsgroups: gmane.lisp.guile.devel Subject: Re: [PATCH]: correctly call build-request Date: Tue, 27 Aug 2013 16:12:59 +0100 Message-ID: <87eh9ftbes.fsf@Kagami.home> References: <521CB471.8060505@gmx.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1377616410 11613 80.91.229.3 (27 Aug 2013 15:13:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 27 Aug 2013 15:13:30 +0000 (UTC) Cc: guile-devel@gnu.org To: Alexandru Cojocaru Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Aug 27 17:13:34 2013 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VEKxZ-0007Kc-NL for guile-devel@m.gmane.org; Tue, 27 Aug 2013 17:13:33 +0200 Original-Received: from localhost ([::1]:56946 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEKxZ-0004Cq-8t for guile-devel@m.gmane.org; Tue, 27 Aug 2013 11:13:33 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEKxM-0003yL-Cf for guile-devel@gnu.org; Tue, 27 Aug 2013 11:13:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VEKxH-0006S1-7x for guile-devel@gnu.org; Tue, 27 Aug 2013 11:13:20 -0400 Original-Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:60850) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEKxH-0006Ph-1M for guile-devel@gnu.org; Tue, 27 Aug 2013 11:13:15 -0400 Original-Received: by mail-wi0-f175.google.com with SMTP id hi5so11748wib.14 for ; Tue, 27 Aug 2013 08:13:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:references:mail-followup-to:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=6mWmZNsO6e5g0RUAOh1BqGcS6LpS/Et8OSPICvVMWFU=; b=XgOF7p5N3hiAHaVnXZrWtL08yeeLo+f429bPVFez8kevMKMb6JIRLwhRZto0B9ggH3 1rMrTHJtHiv4zOpfphuzOsYlGw0W82ANFv7cGmOplnPErD7bPIUvY0bLR1IXqvqwqRIv 0i+MzhuQAX8/pNy3rYw0LgsNwb749Ybnd5Y6IwlAGSBVTRooDnl63RRTQ7lrGrlvZlFp eLKAkYcy85o+h/wz4zTReEhv2cZp9CdPF+7QurQS0qm+4hKDXx4az26K/2JqyHOeJlUh fY08Wysjmx8RaZ4H2U6nGWK/VDj5dfoTrCJOVLTtGCgqGfU4riraSeA5uX2eeQhX06r0 X/Sw== X-Received: by 10.180.13.174 with SMTP id i14mr12061028wic.49.1377616386878; Tue, 27 Aug 2013 08:13:06 -0700 (PDT) Original-Received: from Kagami.home (host81-155-241-158.range81-155.btcentralplus.com. [81.155.241.158]) by mx.google.com with ESMTPSA id ff5sm26718335wib.2.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 27 Aug 2013 08:13:05 -0700 (PDT) Mail-Followup-To: Alexandru Cojocaru , guile-devel@gnu.org In-Reply-To: <521CB471.8060505@gmx.com> (Alexandru Cojocaru's message of "Tue, 27 Aug 2013 16:15:13 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22f X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:16579 Archived-At: Alexandru Cojocaru writes: > Hi, > http-post currently sends a GET method instead of POST, I tracked down > the problem > to extend-request. It would have been nice to send an example. It's a little annoying to work backwards from a patch to a bug. :) scheme@(guile-user)> (use-modules (web uri) (web client)) scheme@(guile-user)> (let ((out (open-output-string))) (catch #t (lambda () (http-post (string->uri "http://www.example.com") #:port out #:body "")) (lambda _ (get-output-string out)))) $15 = "GET / HTTP/1.1\r\nContent-Type: text/plain;charset=utf-8\r\nHost: www.example.com\r\nConnection: close\r\n\r\n" > (define (extend-request r k v . additional) > - (let ((r (build-request (request-uri r) #:version (request-version r) > + (let ((r (build-request (request-uri r) > + #:method (request-method r) > + #:version (request-version r) > #:headers > (assoc-set! (copy-tree (request-headers r)) > k v) > - #:port (request-port r)))) > + #:port (request-port r) > + #:meta (request-meta r)))) Seems fine to me. > (if (null? additional) > r > (apply extend-request r additional)))) > @@ -125,7 +128,7 @@ as is the case by default with a request returned by `build-request'." > (cond > ((not body) > (let ((length (request-content-length request))) > - (if length > + (when length > (unless (zero? length) > (error "content-length, but no body")) > (when (assq 'transfer-encoding (request-headers request)) You've merely switched the case around. Previously, when length was #f, and transfer-encoding was asked for, you got an error. Now, when length is not #f, transfer encoding is asked for, and content length is zero, you get an error. The latter does not generalise the former. The correct thing should be more like (untested) (when (and length (not (zero? length))) (error "content-length, but no body")) (when (assq 'transfer-encoding (request-headers request)) (error "transfer-encoding not allowed with no body")) (values request #vu8) That said, why do we forbid transfer encoding? Pointless though it may be, I don't think there is a technical or standards reason why it shouldn't work. -- Ian Price -- shift-reset.com "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled"