Python Requests logging 401 immediately before 200

Zach Dunlap zrdunlap at gmail.com
Fri Feb 20 12:16:11 EST 2015


Hi everyone,

I'm using MarkLogic and have a Python script set up to check for documents using Requests (http://docs.python-requests.org/en/latest/) and I have logging included in the script.

I have logging set to the DEBUG level.

When I set the script to simple search and return the HTTP status code for items it works, but when I look at what is generated by logging I see the following for everything:

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.

When I search for a document using something like CURL for instance, I only get the 200 status code which seems correct to me.

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?

Thank you for your help!

Here's a snipped of my code in case it helps:

import requests
import logging

# initiate logging
log_path = os.path.join('my_log.log')
logging.basicConfig(filename=log_path,level=logging.DEBUG)

# make request
r = requests.get('http://localhost:8004/v1/documents?uri=000248e4331d4db5856df8fd427b3cdb.xml',auth=HTTPDigestAuth('USER', 'PASSWORD'))

print r.status_code



More information about the Python-list mailing list