mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
stuff and things and stuff
This commit is contained in:
+3
-9
@@ -18,16 +18,9 @@ from datetime import datetime
|
||||
from .auth import dispatch as auth_dispatch
|
||||
from .hooks import dispatch_hook
|
||||
from .structures import CaseInsensitiveDict
|
||||
from .packages.poster.encode import multipart_encode
|
||||
from .packages.poster.streaminghttp import register_openers, get_handlers
|
||||
from .status_codes import codes
|
||||
from .exceptions import Timeout, URLRequired, TooManyRedirects
|
||||
from .monkeys import Request as _Request
|
||||
from .monkeys import HTTPRedirectHandler
|
||||
from .exceptions import Timeout, URLRequired, TooManyRedirects, RequestException, HTTPError
|
||||
from .exceptions import Timeout, URLRequired, TooManyRedirects
|
||||
from .monkeys import Request as _Request
|
||||
from .monkeys import HTTPRedirectHandler
|
||||
from .exceptions import Timeout, URLRequired, TooManyRedirects, HTTPError
|
||||
|
||||
from .utils import (
|
||||
dict_from_cookiejar, get_unicode_from_response,
|
||||
stream_decode_response_unicode, decode_gzip, stream_decode_gzip)
|
||||
@@ -190,6 +183,7 @@ class Request(object):
|
||||
|
||||
# Start off with our local cookies.
|
||||
cookies = self.cookies or dict()
|
||||
print ' %s' % str(cookies)
|
||||
|
||||
# Add new cookies from the server.
|
||||
if 'set-cookie' in response.headers:
|
||||
|
||||
@@ -9,12 +9,10 @@ requests (cookies, auth, proxies).
|
||||
|
||||
"""
|
||||
|
||||
import cookielib
|
||||
|
||||
from .defaults import defaults
|
||||
from .models import Request
|
||||
from .hooks import dispatch_hook
|
||||
from .utils import add_dict_to_cookiejar, cookiejar_from_dict, header_expand
|
||||
from .utils import header_expand
|
||||
from .packages.urllib3.poolmanager import PoolManager
|
||||
|
||||
|
||||
@@ -87,7 +85,7 @@ class Session(object):
|
||||
)
|
||||
|
||||
# Set up a CookieJar to be used by default
|
||||
self.cookies = cookielib.FileCookieJar()
|
||||
self.cookies = {}
|
||||
|
||||
def __repr__(self):
|
||||
return '<requests-client at 0x%x>' % (id(self))
|
||||
@@ -135,11 +133,6 @@ class Session(object):
|
||||
if cookies is None:
|
||||
cookies = {}
|
||||
|
||||
if isinstance(cookies, dict):
|
||||
cookies = add_dict_to_cookiejar(self.cookies, cookies)
|
||||
|
||||
cookies = cookiejar_from_dict(cookies)
|
||||
|
||||
# Expand header values
|
||||
if headers:
|
||||
for k, v in headers.items() or {}:
|
||||
|
||||
+12
-3
@@ -4,13 +4,12 @@
|
||||
from __future__ import with_statement
|
||||
|
||||
import time
|
||||
import cookielib
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import requests
|
||||
import envoy
|
||||
from urllib2 import HTTPError
|
||||
from requests import HTTPError
|
||||
|
||||
try:
|
||||
import omnijson as json
|
||||
@@ -235,7 +234,8 @@ class RequestsTestSuite(unittest.TestCase):
|
||||
for service in SERVICES:
|
||||
|
||||
r = requests.get(service('status', '404'))
|
||||
print r.status_code
|
||||
# print r.status_code
|
||||
# r.raise_for_status()
|
||||
self.assertEqual(r.ok, False)
|
||||
|
||||
|
||||
@@ -510,6 +510,15 @@ class RequestsTestSuite(unittest.TestCase):
|
||||
assert params3['b'] in r3.content
|
||||
assert params3['c'] in r3.content
|
||||
|
||||
def test_cookies(self):
|
||||
|
||||
s = requests.session()
|
||||
r = s.get(httpbin('cookies', 'set', 'face', 'book'))
|
||||
print r.headers
|
||||
print r.history[0].cookies
|
||||
print r.content
|
||||
print r.url
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user