Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

Commit

Permalink
fix(cookie): Use cookie jar for HTTP requests from HTTP agent.
Browse files Browse the repository at this point in the history
  • Loading branch information
joonlim committed Mar 25, 2019
1 parent a88a8da commit 19c6dc5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions citest/service_testing/http_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@
import traceback

try:
from urllib2 import urlopen
from urllib2 import build_opener
from urllib2 import Request
from urllib2 import HTTPCookieProcessor
from urllib2 import HTTPSHandler
from urllib2 import HTTPError
from urllib2 import URLError
except ImportError:
from urllib.request import urlopen
from urllib.request import build_opener
from urllib.request import Request
from ulllib.request import HTTPCookieProcessor
from ulllib.request import HTTPSHandler
from urllib.error import HTTPError
from urllib.error import URLError

Expand Down Expand Up @@ -434,17 +438,19 @@ def __send_http_request(self, path, http_type, data=None, headers=None):
_logger=self.logger,
_context='request')

context = None
if self.__ignore_ssl_cert_verification:
context = ssl._create_unverified_context()
opener = build_opener(HTTPSHandler(context=context), HTTPCookieProcessor())
else:
opener = build_opener(HTTPCookieProcessor())

code = None
output = None
exception = None
headers = None

try:
response = urlopen(req, context=context)
response = opener.open(req)
code = response.getcode()
output = bytes.decode(response.read())
if sys.version_info[0] > 2:
Expand Down

0 comments on commit 19c6dc5

Please sign in to comment.