# Path: apiritif/ssl_adapter.py
# class SSLAdapter(HTTPAdapter):
#     def __init__(self, *args, **kwargs):
#         certificate_file_path = kwargs.pop('certificate_file_path', None)
#         passphrase = kwargs.pop('passphrase', None)
# 
#         pkcs12_obj = CertificateReader.create_pkcs12_obj(certificate_file_path, passphrase)
#         self.ssl_context = CertificateReader.create_ssl_context(pkcs12_obj)
# 
#         super(SSLAdapter, self).__init__(*args, **kwargs)
# 
#     def init_poolmanager(self, *args, **kwargs):
#         if self.ssl_context:
#             kwargs['ssl_context'] = self.ssl_context
#         return super(SSLAdapter, self).init_poolmanager(*args, **kwargs)
# 
#     def proxy_manager_for(self, *args, **kwargs):
#         if self.ssl_context:
#             kwargs['ssl_context'] = self.ssl_context
#         return super(SSLAdapter, self).proxy_manager_for(*args, **kwargs)
# 
# Path: apiritif/thread.py
# def get_from_thread_store(names=None):
#     if names and hasattr(_thread_local, "kwargs"):
#         only_one = False
#         if isinstance(names, str):
#             names = [names]
#             only_one = True
#         kwargs = [_thread_local.kwargs.get(key) for key in names]
#         if only_one:
#             return kwargs[0]
#         else:
#             return kwargs
# 
#     elif hasattr(_thread_local, "args"):
#         return _thread_local.args
# 
# def put_into_thread_store(*args, **kwargs):
#     if args:
#         _thread_local.args = args
#     if kwargs:
#         current_kwargs = getattr(_thread_local, "kwargs", {})
#         current_kwargs.update(kwargs)
#         _thread_local.kwargs = current_kwargs
# 
# Path: apiritif/utils.py
# VERSION = "1.1.3"
# def get_trace(error):
# def graceful():
# def headers_as_text(headers_dict):
# def shorten(string, upto, end_with="..."):
# def assert_regexp(regex, text, match=False, msg=None):
# def assert_not_regexp(regex, text, match=False, msg=None):
# class NormalShutdown(BaseException):


import copy
import os
import threading
import time
import requests
import apiritif
from functools import wraps
from io import BytesIO
from jsonpath_ng.ext import parse as jsonpath_parse
from lxml import etree, html
from requests.structures import CaseInsensitiveDict
from apiritif.ssl_adapter import SSLAdapter
from apiritif.thread import get_from_thread_store, put_into_thread_store
from apiritif.utilities import *
from apiritif.utils import headers_as_text, assert_regexp, assert_not_regexp, log, get_trace, NormalShutdown, graceful

Copyright 2017 BlazeMeter Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""



BODY_LIMIT = int(os.environ.get("APIRITIF_TRACE_BODY_EXCLIMIT", "1024"))


class TimeoutError(Exception):
    pass


class ConnectionError(Exception):
    pass


class http(object):

# Path: apiritif/ssl_adapter.py
# class SSLAdapter(HTTPAdapter):
#     def __init__(self, *args, **kwargs):
#         certificate_file_path = kwargs.pop('certificate_file_path', None)
#         passphrase = kwargs.pop('passphrase', None)
# 
#         pkcs12_obj = CertificateReader.create_pkcs12_obj(certificate_file_path, passphrase)
#         self.ssl_context = CertificateReader.create_ssl_context(pkcs12_obj)
# 
#         super(SSLAdapter, self).__init__(*args, **kwargs)
# 
#     def init_poolmanager(self, *args, **kwargs):
#         if self.ssl_context:
#             kwargs['ssl_context'] = self.ssl_context
#         return super(SSLAdapter, self).init_poolmanager(*args, **kwargs)
# 
#     def proxy_manager_for(self, *args, **kwargs):
#         if self.ssl_context:
#             kwargs['ssl_context'] = self.ssl_context
#         return super(SSLAdapter, self).proxy_manager_for(*args, **kwargs)
# 
# Path: apiritif/thread.py
# def get_from_thread_store(names=None):
#     if names and hasattr(_thread_local, "kwargs"):
#         only_one = False
#         if isinstance(names, str):
#             names = [names]
#             only_one = True
#         kwargs = [_thread_local.kwargs.get(key) for key in names]
#         if only_one:
#             return kwargs[0]
#         else:
#             return kwargs
# 
#     elif hasattr(_thread_local, "args"):
#         return _thread_local.args
# 
# def put_into_thread_store(*args, **kwargs):
#     if args:
#         _thread_local.args = args
#     if kwargs:
#         current_kwargs = getattr(_thread_local, "kwargs", {})
#         current_kwargs.update(kwargs)
#         _thread_local.kwargs = current_kwargs
# 
# Path: apiritif/utils.py
# VERSION = "1.1.3"
# def get_trace(error):
# def graceful():
# def headers_as_text(headers_dict):
# def shorten(string, upto, end_with="..."):
# def assert_regexp(regex, text, match=False, msg=None):
# def assert_not_regexp(regex, text, match=False, msg=None):
# class NormalShutdown(BaseException):


# Path: apiritif/http.py
import copy
import os
import threading
import time
import requests
import apiritif
from functools import wraps
from io import BytesIO
from jsonpath_ng.ext import parse as jsonpath_parse
from lxml import etree, html
from requests.structures import CaseInsensitiveDict
from apiritif.ssl_adapter import SSLAdapter
from apiritif.thread import get_from_thread_store, put_into_thread_store
from apiritif.utilities import *
from apiritif.utils import headers_as_text, assert_regexp, assert_not_regexp, log, get_trace, NormalShutdown, graceful


Copyright 2017 BlazeMeter Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""



BODY_LIMIT = int(os.environ.get("APIRITIF_TRACE_BODY_EXCLIMIT", "1024"))


class TimeoutError(Exception):
    pass


class ConnectionError(Exception):
    pass


class http(object):

    log = log.getChild('http')