From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sean Allred Newsgroups: gmane.emacs.help Subject: Re: url-retrieve-synchronously results differ from curl Date: Wed, 21 Jan 2015 09:27:16 -0500 Message-ID: <566AE86E-63C5-4ED5-81F4-2619DE70069F@seanallred.com> References: <87y4oxewcc.fsf@yahoo.fr> <87d26861z5.fsf@yahoo.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1421853225 30862 80.91.229.3 (21 Jan 2015 15:13:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Jan 2015 15:13:45 +0000 (UTC) Cc: help-gnu-emacs , Artur Malabarba To: Nicolas Richard Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jan 21 16:13:43 2015 Return-path: Envelope-to: geh-help-gnu-emacs@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 1YDwyR-0000Ga-2k for geh-help-gnu-emacs@m.gmane.org; Wed, 21 Jan 2015 16:13:39 +0100 Original-Received: from localhost ([::1]:48743 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDwyQ-00059R-1q for geh-help-gnu-emacs@m.gmane.org; Wed, 21 Jan 2015 10:13:38 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDwFg-0004fj-DL for help-gnu-emacs@gnu.org; Wed, 21 Jan 2015 09:27:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDwFc-0003t7-SW for help-gnu-emacs@gnu.org; Wed, 21 Jan 2015 09:27:24 -0500 Original-Received: from sub4.mail.dreamhost.com ([69.163.253.135]:47149 helo=homiemail-a64.g.dreamhost.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDwFc-0003qH-FF for help-gnu-emacs@gnu.org; Wed, 21 Jan 2015 09:27:20 -0500 Original-Received: from homiemail-a64.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a64.g.dreamhost.com (Postfix) with ESMTP id E8FC043807F; Wed, 21 Jan 2015 06:27:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=seanallred.com; h= content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; s=seanallred.com; bh=R8wRAeXjrkQ+2CMj TwuyPdHroB8=; b=Kl/CEFUF71OBML8GwSanVAYS5OuvErRPTCbJXLRiGeq90UqC BCBsx/GTtVKzjYO80zZnBSCkAFdsm+8r16Ao3+UBXM/NEPe/RjjXpqh1VujE/MLn QWx+Ntb0ibQWNbl48dKm6iNuH+xt5EPmqU7cszW6l7csnE+IlkNsSlLKRZM= Original-Received: from [10.0.1.9] (c-50-190-161-55.hsd1.md.comcast.net [50.190.161.55]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: code@seanallred.com) by homiemail-a64.g.dreamhost.com (Postfix) with ESMTPSA id 76088438079; Wed, 21 Jan 2015 06:27:17 -0800 (PST) In-Reply-To: <87d26861z5.fsf@yahoo.fr> X-Mailer: Apple Mail (2.1993) X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 69.163.253.135 X-Mailman-Approved-At: Wed, 21 Jan 2015 10:13:25 -0500 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:102198 Archived-At: Artur discovered something this morning that I wanted to share here as = he works on a proper bug report. (We=E2=80=99re both especially busy = today, unfortunately.) Perhaps someone can shed light on this behavior. Binding `url-request-method` to `=E2=80=9DPOST=E2=80=9D` rather than = `=E2=80=9Dpost=E2=80=9D` seems to fix the issues en masse. This has not = undergone proper testing, but it definitely seems to work [1]. I = apologize that I don=E2=80=99t have an example that works out-of-the-box = =E2=80=93 I really have a very limited experience with web stuff =E2=80=93= but using =E2=80=9CPOST=E2=80=9D rather than =E2=80=9Cpost=E2=80=9D = makes a significant difference. The question we both have at this point is *why* =E2=80=93 *why* does = =E2=80=9Cpost=E2=80=9D =E2=80=98partly=E2=80=99 work? *Why* does = =E2=80=9CPOST=E2=80=9D work fully? And frankly, in my personal opinion, = *why* aren=E2=80=99t these methods taken in as symbols in the first = place? Either Artur or I will be filing a proper bug report for url.el on this = issue as time allows (assuming of course that someone doesn=E2=80=99t = beat both of us to it). (Unless this thread can count as a bug-report?) All the best, Sean Allred [1]: https://gist.github.com/90be70f12cd097be1247 = , reproduced below (defconst tmp:access-token ;; Needed to post answers. Considered a secret. If you would like ;; a key, use `sx-authenticate' from sx.el (available from MELPA) ;; and look in ~/.emacs.d/.sx/auth.el "YOUR ACCESS TOKEN HERE") (defconst tmp:key ;; not considered a secret "0TE6s1tveCpP9K5r5JNDNQ((") (defun tmp:api-bug (use-curl access-token key) "Post a test answer to the formatting sandbox." (let ((random-body-1 (md5 (current-time-string))) (random-body-2 (md5 (md5 (current-time-string)))) (method = "https://api.stackexchange.com/2.2/questions/3122/answers/add") (args (mapconcat #'identity `(,(format "access_token=3D%s" (replace-regexp-in-string "%" "%%" (url-hexify-string access-token))) ,(format "key=3D%s" (replace-regexp-in-string "%" "%%" (url-hexify-string key))) "site=3Dmeta" "pagesize=3D100" = "filter=3D%%21GoYr1we0U5inG5G7wBg4JBGpbgX%%29C7LDqpy-%%2AbfwPOujOr4SR4W%%2= 9bLNSyYUpQDdTwTj.XChTFB0gfLaAJq0hv" "body=3Dthis-is-an-answer-test-for-sx.el--%s") "&"))) (if use-curl (shell-command-to-string (format "curl --silent -X POST --data %S %s | gunzip" (format args random-body-2) method)) (let ((url-automatic-caching t) (url-inhibit-uncompression t) (url-request-data (format args random-body-1)) ;; emacs-devel: note vvvv (url-request-method "POST") (url-request-extra-headers '(("Content-Type" . "application/x-www-form-urlencoded")))) (with-current-buffer (url-retrieve-synchronously method) (goto-char (point-min)) (search-forward "\n\n") (delete-region (point-min) (point)) (buffer-string)))))) (require 'json) (json-read-from-string (tmp:api-bug t tmp:access-token tmp:key)) ((total . 1) ; this data structure used curl (page_size . 100) (page . 1) (quota_remaining . 9979) (quota_max . 10000) (has_more . :json-false) (items . [((link . = "http://meta.stackexchange.com/questions/3122//247295#247295") (body_markdown . = "this-is-an-answer-test-for-sx.el--e3eeb6228ed9c2c58e5385b73493f0f0") (share_link . "http://meta.stackexchange.com/a/247295/188148") (answer_id . 247295) (creation_date . 1421684370) (last_activity_date . 1421684370) (score . 0) (upvoted . :json-false) (downvoted . :json-false) (owner (display_name . "Sean Allred") (reputation . 160)))])) (json-read-from-string (tmp:api-bug nil tmp:access-token tmp:key)) ((total . 1) ; this data structure used = "POST" (page_size . 100) (page . 1) (quota_remaining . 9999) (quota_max . 10000) (has_more . :json-false) (items . [((link . = "http://meta.stackexchange.com/questions/3122//247396#247396") (body_markdown . = "this-is-an-answer-test-for-sx.el--5b447b87e7078ed0fd34a3169ee84319") (share_link . "http://meta.stackexchange.com/a/247396/188148") (answer_id . 247396) (creation_date . 1421847252) (last_activity_date . 1421847252) (score . 0) (upvoted . :json-false) (downvoted . :json-false) (owner (display_name . "Sean Allred") (reputation . 160)))])) ((total . 1) ; this data structure used = "post" (page_size . 100) (page . 1) (quota_remaining . 9977) (quota_max . 10000) (has_more . :json-false) (items . [((link . = "http://meta.stackexchange.com/questions/3122//247297#247297") (share_link . "http://meta.stackexchange.com/a/247297/188148") (answer_id . 247297) (creation_date . 1421684555) (last_activity_date . 1421684555) (score . 0) (owner (display_name . "Sean Allred") (reputation . 160)))]))