Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85981
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.049 |
| X-Spam-Evidence | '*H*': 0.90; '*S*': 0.00; 'digest': 0.04; 'subject:Python': 0.06; '21,': 0.07; 'puts': 0.07; 'credentials,': 0.09; 'executed': 0.09; 'http': 0.09; 'url:localhost': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'localhost': 0.16; 'query,': 0.16; 'subject:immediately': 0.16; 'sat,': 0.16; 'so.': 0.16; 'fix': 0.17; 'wrote:': 0.18; '(not': 0.18; 'bit': 0.19; 'module': 0.19; 'basically': 0.19; 'server,': 0.19; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'load': 0.23; "shouldn't": 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'am,': 0.29; 'needed.': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'requests': 0.31; 'credentials': 0.31; "they'll": 0.31; 'file': 0.32; 'url:non-standard http port': 0.33; 'problem': 0.35; "can't": 0.35; 'advice': 0.35; 'connection': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'doing': 0.36; 'should': 0.36; 'wrong': 0.37; 'level': 0.37; 'easily': 0.37; 'performance': 0.37; 'server': 0.38; 'configured': 0.38; 'massive': 0.38; 'issue': 0.38; 'short': 0.38; 'sure': 0.39; 'even': 0.60; 'easy': 0.60; 'logs': 0.60; 'signal': 0.60; 'skip:i 50': 0.60; 'worry': 0.60; 'tell': 0.60; 'new': 0.61; "you're": 0.61; 'first': 0.61; 'spam.': 0.64; 'more': 0.64; 'here': 0.66; 'debate': 0.68; 'nobody': 0.68; 'skip:r 40': 0.68; 'internet': 0.71; '2015': 0.84; 'about?': 0.84; 'explanation:': 0.84; 'inevitable': 0.84; 'subject:before': 0.84; 'url:documents': 0.84; 'url:uri': 0.84; 'url:v1': 0.84; 'to:none': 0.92; 'hand,': 0.93; 'unsolicited': 0.95 |
| 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:cc :content-type; bh=OmpUBCy/wNvUYx080v4QUP0sKHMsCmETEBwyqBKjSHo=; b=YzcyoGXVE0wIterme+PEjMTMsJ/fEd8g5UrVyC6G6lILaXwT0hx6SlgdQXzpir+1Os wguF8McFgCmpTFLJZdQyFjA//XmWoRIvaqRccRHSwafMXlkJ2a0r2+sNo6dCmQPmzJ8o PU99rdyB7bIX8bIj3g03A0Mpp1U6zGVJize/OQOk1CJbkGB816sLikX03j2iPFjqbaHp 8vSASvX3g7qnAz8DQ9TPiIP8gi4wUJTFBxoyuNiEADMQxIOy27hNx7wEBUWBiaPudvOs Ay/IXfVWJKH++VCAObxJnnYOjtH+5YDOFLkGMnHp3eFbuzFhACBVLW/5RzVagQTwVPDC 3lqg== |
| MIME-Version | 1.0 |
| X-Received | by 10.107.33.11 with SMTP id h11mr14603063ioh.53.1424453421078; Fri, 20 Feb 2015 09:30:21 -0800 (PST) |
| In-Reply-To | <6349a85a-f13e-47b1-a5c1-6c87cd96fa2e@googlegroups.com> |
| References | <6349a85a-f13e-47b1-a5c1-6c87cd96fa2e@googlegroups.com> |
| Date | Sat, 21 Feb 2015 04:30:21 +1100 |
| Subject | Re: Python Requests logging 401 immediately before 200 |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.18926.1424453424.18130.python-list@python.org> (permalink) |
| Lines | 37 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1424453424 news.xs4all.nl 2868 [2001:888:2000:d::a6]:45305 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:85981 |
Show key headers only | View raw
On Sat, Feb 21, 2015 at 4:16 AM, Zach Dunlap <zrdunlap@gmail.com> wrote:
> INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): localhost
> DEBUG:requests.packages.urllib3.connectionpool:"GET /v1/documents?uri=000248e4331d4db5856df8fd427b3cdb.xml HTTP/1.1" 401 211
> DEBUG:requests.packages.urllib3.connectionpool:"GET /v1/documents?uri=000248e4331d4db5856df8fd427b3cdb.xml HTTP/1.1" 200 18327
>
> As you can see the 400 and the 200 are the same document (only 1 can exist in ML with the same URI) and in MarkLogic's logs both are executed at the same time.
>
> Is this something I should be concerned about and should fix or is it just the log level I have set or something else I shouldn't worry about?
>
> r = requests.get('http://localhost:8004/v1/documents?uri=000248e4331d4db5856df8fd427b3cdb.xml',auth=HTTPDigestAuth('USER', 'PASSWORD'))
>
Short explanation: It's part of the protocol.
You're using Digest Auth, so what's happening here is that a request
is sent without the authentication, and the inevitable 401 response is
the signal that the request should be re-sent with credentials.
There's a massive debate as to whether or not it's correct to send
unsolicited credentials. On the one hand, this "401 then 200" pattern
takes extra internet round-trips (not that that's a big deal with
localhost, but it's the same issue everywhere) and puts extra load on
both server and client; but on the other hand, nobody wants their
credentials sent to the wrong server, and it's not always easy to tell
when they'll be needed. Without the 401, you can't know whether or not
you need to authenticate, so if once you start sending unsolicited
credentials, you basically have to keep on doing so.
If you don't have a problem with performance or latency, then consider
this to be nothing more than a bit of log file spam. I'm not sure if
the Python requests module can be easily configured to send
credentials on the first query, but my advice is: don't even bother
looking into that unless you have need to.
All the best!
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python Requests logging 401 immediately before 200 Zach Dunlap <zrdunlap@gmail.com> - 2015-02-20 09:16 -0800
Re: Python Requests logging 401 immediately before 200 Chris Angelico <rosuav@gmail.com> - 2015-02-21 04:30 +1100
Re: Python Requests logging 401 immediately before 200 Zach Dunlap <zrdunlap@gmail.com> - 2015-02-20 09:39 -0800
Re: Python Requests logging 401 immediately before 200 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-02-20 18:34 +0000
csiph-web