Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 89D9D10F9E for ; Thu, 14 Nov 2013 17:01:01 +0000 (UTC) Received: (qmail 9792 invoked by uid 500); 14 Nov 2013 17:00:13 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 9754 invoked by uid 500); 14 Nov 2013 17:00:11 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 9707 invoked by uid 99); 14 Nov 2013 17:00:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Nov 2013 17:00:06 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,RCVD_IN_DNSWL_LOW,SPF_PASS,URI_NOVOWEL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of hknight555@gmail.com designates 74.125.82.47 as permitted sender) Received: from [74.125.82.47] (HELO mail-wg0-f47.google.com) (74.125.82.47) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Nov 2013 17:00:02 +0000 Received: by mail-wg0-f47.google.com with SMTP id y10so2254203wgg.26 for ; Thu, 14 Nov 2013 08:59:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=txPqGw4tUSNVMMM8+3d9h+BfKfErrTdqm2WQ8V3G7Ec=; b=s7h1vUos7m9PYQJGRt76nP5S103Sq7YPIzkRNjGv8diivdSDjqsxkfa59wOynTVrXv gW4C7+M6KBfbIclnrbXMu0VbpLY8kt53TpQelvgdouF2i0sIYamji85/eHWc+tzMaNud XZBv1PDZ0A7j00e6IVtRBuHu68N5OKoxgS1Gn5ebLx77T3DRCewsqKUbDWLXuAW/Qhhf zaYJw6jDG81rRLynSqSN9pgKfB3sDFNIL2bhLnbY/DckCCFOkpwvKW/rPlo7vyqgWUJO LocZysgC0p9L9H7rPSqIXN9jOBEW8g+vR5EIudEfiXj30RcRBvIeIOgGJxioutxrGlCI Z8Uw== MIME-Version: 1.0 X-Received: by 10.180.94.100 with SMTP id db4mr3738519wib.14.1384448380646; Thu, 14 Nov 2013 08:59:40 -0800 (PST) Received: by 10.216.3.9 with HTTP; Thu, 14 Nov 2013 08:59:40 -0800 (PST) In-Reply-To: References: Date: Thu, 14 Nov 2013 12:59:40 -0400 Message-ID: Subject: Re: CouchDB: @ in username messing up curl From: Hank Knight To: user@couchdb.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Thanks, guys. You were right, the problem was not actually the @! This works: curl -k -u nlbdmobz@sharklasers.com:password123 \ -X POST https://zqzqzqz555.couchappy.com/urls \ -d "{}" -H "Content-Type: application/json" On Thu, Nov 14, 2013 at 4:49 AM, Dave Cottlehuber wrote= : > On 14. November 2013 at 03:04:22, Hank Knight (hknight555@gmail.com) wrot= e: >> >> What is wrong with this? > > > The main error is that you=92re not using `curl -v=85` by default. > > If so you=92d see: > > curl -vkX -u nlbdmobz\%40sharklasers.com:password123 POST https://zqzqzqz= 555.couchappy.com/urls -d "{}" -H "Content-Type: application/json" > * Rebuilt URL to: nlbdmobz%40sharklasers.com:password123/ > * Adding handle: conn: 0x7f962981ba00 > * Adding handle: send: 0 > * Adding handle: recv: 0 > * Curl_addHandleToPipeline: length: 1 > * - Conn 0 (0x7f962981ba00) send_pipe: 1, recv_pipe: 0 > * Could not resolve: nlbdmobz%40sharklasers.com (Could not contact DNS se= rvers) > * Closing connection 0 > > > Aha!!! > >> curl -kX -u nlbdmobz@sharklasers.com:password123 POST \ >> https://zqzqzqz555.couchappy.com/urls \ >> -d "{}" -H "Content-Type: application/json" >> >> I get an error: >> curl: (6) Couldn't resolve host 'sharklasers.com:password123' >> >> I think the problem is because of the @ in the username. How can >> this be fixed? >> >> The database, username and password in the example above are >> all real >> so you may test it verbatim. >> >> Thanks! > > The error message is insightful (once you know what you=92re looking for!= ) > > couldn't resolve host 'sharklasers.com:password123=92 > > Your curl parameters are in the wrong order, and what you think is being > used as the arguments to -u are being picked up by the -X parameter first= , > and parsed as the hostname. > > Fix that and it works. > > I find with curl & couchdb you need to split out auth from other operatio= ns, i.e. get auth working with GET /, and then add in your posts or views. > > Also for console testing of couchdb, I highly recommend the amazing http:= //httpie.org/ python tool: > > ```shell > $ pip install httpie > $ http --verify=3Dno --json --pretty all --verbose --style fruity \ > --auth-type basic --auth nlbdmobz@sharklasers.com:password123 \ > get https://zqzqzqz555.couchappy.com/ > > GET / HTTP/1.1 > Accept: application/json > Accept-Encoding: gzip, deflate, compress > Authorization: Basic bmxiZG1vYnpAc2hhcmtsYXNlcnMuY29tOnBhc3N3b3JkMTIz > Content-Type: application/json; charset=3Dutf-8 > Host: zqzqzqz555.couchappy.com > User-Agent: HTTPie/0.8.0-dev > > HTTP/1.1 200 OK > Cache-Control: must-revalidate > Content-Length: 151 > Content-Type: application/json > Date: Thu, 14 Nov 2013 08:42:49 GMT > Server: CouchDB/1.3.0 (Erlang OTP/R15B01) > > { > "couchdb": "Welcome to Couchappy", > "uuid": "040ec65fed39bc70c14f8f7dc1a0c8b6", > "vendor": { > "name": "www.couchappy.com", > "version": "1.3.0" > }, > "version": "1.3.0" > } > ``` > > Now you can add in your POST parameters safely. > > A+ > Dave >