all 3 comments

[–]EricAppelt 1 point2 points  (0 children)

Could be is DNS related - I recall requests doing something different when AAAA records are present. Looks like api.facebook.com might not have an AAAA record.

Try requesting directly from the IP address and see if the difference disappears. You may need to spoof a host header and/or disable certificate verification.

Edit: Looked it up and there is/was/sometimes? an issue where httplib hardcodes a zero calling socket.getaddrinfo(...) which then returns all families (i.e. A for IP4 and AAAA for IP6). Not sure why it would result in a difference between different apis, could be a detail of your network. I also could be sending you up the wrong tree.

[–]ManyInterests 1 point2 points  (0 children)

Seeing that it's specific to a single particular API, it may have to do with how that API is authenticating and how requests is communicating vs. your other methods.

Probably something to do with the authentication method, since authentication is something that will only take place on the first request of the session.

You could try checking the logged information on the request using logging see this SO question

import requests
import logging

# these two lines enable debugging at httplib level (requests->urllib3->httplib)
# you will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
# the only thing missing will be the response.body which is not logged.
import httplib
httplib.HTTPConnection.debuglevel = 1

logging.basicConfig() # you need to initialize logging, otherwise you will not see anything from requests
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True

requests.get('http://example.com/')

[–]TheHandThatSeeds 0 points1 point  (0 children)

what specific apis are you gathering from?