# Path: heatclient/common/http.py
# LOG = logging.getLogger(__name__)
# USER_AGENT = 'python-heatclient'
# CHUNKSIZE = 1024 * 64  # 64kB
# SENSITIVE_HEADERS = ('X-Auth-Token',)
# def authenticated_fetcher(hc):
#     def _do(*args, **kwargs):
# def get_system_ca_file():
#     def __init__(self, endpoint, **kwargs):
#     def safe_header(self, name, value):
#     def log_curl_request(self, method, url, kwargs):
#     def log_http_response(resp):
#     def _http_request(self, url, method, **kwargs):
#     def credentials_headers(self):
#     def json_request(self, method, url, **kwargs):
#     def raw_request(self, method, url, **kwargs):
#     def client_request(self, method, url, **kwargs):
#     def head(self, url, **kwargs):
#     def get(self, url, **kwargs):
#     def post(self, url, **kwargs):
#     def put(self, url, **kwargs):
#     def delete(self, url, **kwargs):
#     def patch(self, url, **kwargs):
#     def request(self, url, method, **kwargs):
#     def credentials_headers(self):
#     def strip_endpoint(self, location):
# def _construct_http_client(endpoint=None, username=None, password=None,
#                            include_pass=None, endpoint_type=None,
#                            auth_url=None, **kwargs):
# class HTTPClient(object):
# class SessionClient(adapter.LegacyJsonAdapter):
# 
# Path: heatclient/common/utils.py
# LOG = logging.getLogger(__name__)
# def arg(*args, **kwargs):
#     def _decorator(func):
# def env(*args, **kwargs):
# def add_arg(func, *args, **kwargs):
# def print_list(objs, fields, formatters=None, sortby_index=0,
#                mixed_case_fields=None, field_labels=None):
# def link_formatter(links):
#     def format_link(l):
# def resource_nested_identifier(rsrc):
# def json_formatter(js):
# def yaml_formatter(js):
# def text_wrap_formatter(d):
# def newline_list_formatter(r):
# def print_dict(d, formatters=None):
#     def __init__(self):
#     def prepend_paths(self, resource_path, stack_id):
#     def build_resource_name(self, event):
#         def get_stack_id():
# def event_log_formatter(events, event_log_context=None):
# def print_update_list(lst, fields, formatters=None):
# def find_resource(manager, name_or_id):
# def format_parameters(params, parse_semicolon=True):
# def format_all_parameters(params, param_files,
#                           template_file=None, template_url=None):
# def format_parameter_file(param_files, template_file=None,
#                           template_url=None):
# def resolve_param_get_file(file, base_url):
# def format_output(output, format='yaml'):
# def parse_query_url(url):
# def get_template_url(template_file=None, template_url=None):
# def read_url_content(url):
# def base_url_for_url(url):
# def normalise_file_path_to_url(path):
# def get_response_body(resp):
# class EventLogContext(object):
# 
# Path: heatclient/exc.py
# class BaseException(Exception):
# class CommandError(BaseException):
# class InvalidEndpoint(BaseException):
# class CommunicationError(BaseException):
# class HTTPException(BaseException):
# class HTTPMultipleChoices(HTTPException):
# class BadRequest(HTTPException):
# class HTTPBadRequest(BadRequest):
# class Unauthorized(HTTPException):
# class HTTPUnauthorized(Unauthorized):
# class Forbidden(HTTPException):
# class HTTPForbidden(Forbidden):
# class NotFound(HTTPException):
# class HTTPNotFound(NotFound):
# class NoUniqueMatch(HTTPException):
# class HTTPMethodNotAllowed(HTTPException):
# class Conflict(HTTPException):
# class HTTPConflict(Conflict):
# class OverLimit(HTTPException):
# class HTTPOverLimit(OverLimit):
# class HTTPUnsupported(HTTPException):
# class HTTPInternalServerError(HTTPException):
# class HTTPNotImplemented(HTTPException):
# class HTTPBadGateway(HTTPException):
# class ServiceUnavailable(HTTPException):
# class HTTPServiceUnavailable(ServiceUnavailable):
# class NoTokenLookupException(Exception):
# class EndpointNotFound(Exception):
# class StackFailure(Exception):
#     def __init__(self, message=None):
#     def __str__(self):
#     def __init__(self, message=None, code=None):
#     def __str__(self):
#     def __str__(self):
# def from_response(response):


import socket
import six
import testtools
from unittest import mock
from keystoneauth1 import adapter
from oslo_serialization import jsonutils
from heatclient.common import http
from heatclient.common import utils
from heatclient import exc
from heatclient.tests.unit import fakes
                               'User-Agent': 'python-heatclient'}),
            mock.call('GET', 'http://example.com:8004',
                      allow_redirects=False,
                      headers={'Content-Type': 'application/json',
                               'Accept': 'application/json',
                               'User-Agent': 'python-heatclient'})
        ])

    def test_http_404_json_request(self, mock_request):
        # Record a 404
        mock_request.return_value = fakes.FakeHTTPResponse(
            404, 'OK', {'content-type': 'application/json'},
            '{}')
        client = http.HTTPClient('http://example.com:8004')
        e = self.assertRaises(exc.HTTPNotFound, client.json_request, 'GET', '')
        # Assert that the raised exception can be converted to string
        self.assertIsNotNone(str(e))
        mock_request.assert_called_with(
            'GET', 'http://example.com:8004',
            allow_redirects=False,
            headers={'Content-Type': 'application/json',
                     'Accept': 'application/json',
                     'User-Agent': 'python-heatclient'})

    def test_http_300_json_request(self, mock_request):
        # Record a 300
        mock_request.return_value = fakes.FakeHTTPResponse(
            300, 'OK', {'content-type': 'application/json'},
            '{}')
        # Assert that the raised exception can be converted to string

# Path: heatclient/common/http.py
# LOG = logging.getLogger(__name__)
# USER_AGENT = 'python-heatclient'
# CHUNKSIZE = 1024 * 64  # 64kB
# SENSITIVE_HEADERS = ('X-Auth-Token',)
# def authenticated_fetcher(hc):
#     def _do(*args, **kwargs):
# def get_system_ca_file():
#     def __init__(self, endpoint, **kwargs):
#     def safe_header(self, name, value):
#     def log_curl_request(self, method, url, kwargs):
#     def log_http_response(resp):
#     def _http_request(self, url, method, **kwargs):
#     def credentials_headers(self):
#     def json_request(self, method, url, **kwargs):
#     def raw_request(self, method, url, **kwargs):
#     def client_request(self, method, url, **kwargs):
#     def head(self, url, **kwargs):
#     def get(self, url, **kwargs):
#     def post(self, url, **kwargs):
#     def put(self, url, **kwargs):
#     def delete(self, url, **kwargs):
#     def patch(self, url, **kwargs):
#     def request(self, url, method, **kwargs):
#     def credentials_headers(self):
#     def strip_endpoint(self, location):
# def _construct_http_client(endpoint=None, username=None, password=None,
#                            include_pass=None, endpoint_type=None,
#                            auth_url=None, **kwargs):
# class HTTPClient(object):
# class SessionClient(adapter.LegacyJsonAdapter):
# 
# Path: heatclient/common/utils.py
# LOG = logging.getLogger(__name__)
# def arg(*args, **kwargs):
#     def _decorator(func):
# def env(*args, **kwargs):
# def add_arg(func, *args, **kwargs):
# def print_list(objs, fields, formatters=None, sortby_index=0,
#                mixed_case_fields=None, field_labels=None):
# def link_formatter(links):
#     def format_link(l):
# def resource_nested_identifier(rsrc):
# def json_formatter(js):
# def yaml_formatter(js):
# def text_wrap_formatter(d):
# def newline_list_formatter(r):
# def print_dict(d, formatters=None):
#     def __init__(self):
#     def prepend_paths(self, resource_path, stack_id):
#     def build_resource_name(self, event):
#         def get_stack_id():
# def event_log_formatter(events, event_log_context=None):
# def print_update_list(lst, fields, formatters=None):
# def find_resource(manager, name_or_id):
# def format_parameters(params, parse_semicolon=True):
# def format_all_parameters(params, param_files,
#                           template_file=None, template_url=None):
# def format_parameter_file(param_files, template_file=None,
#                           template_url=None):
# def resolve_param_get_file(file, base_url):
# def format_output(output, format='yaml'):
# def parse_query_url(url):
# def get_template_url(template_file=None, template_url=None):
# def read_url_content(url):
# def base_url_for_url(url):
# def normalise_file_path_to_url(path):
# def get_response_body(resp):
# class EventLogContext(object):
# 
# Path: heatclient/exc.py
# class BaseException(Exception):
# class CommandError(BaseException):
# class InvalidEndpoint(BaseException):
# class CommunicationError(BaseException):
# class HTTPException(BaseException):
# class HTTPMultipleChoices(HTTPException):
# class BadRequest(HTTPException):
# class HTTPBadRequest(BadRequest):
# class Unauthorized(HTTPException):
# class HTTPUnauthorized(Unauthorized):
# class Forbidden(HTTPException):
# class HTTPForbidden(Forbidden):
# class NotFound(HTTPException):
# class HTTPNotFound(NotFound):
# class NoUniqueMatch(HTTPException):
# class HTTPMethodNotAllowed(HTTPException):
# class Conflict(HTTPException):
# class HTTPConflict(Conflict):
# class OverLimit(HTTPException):
# class HTTPOverLimit(OverLimit):
# class HTTPUnsupported(HTTPException):
# class HTTPInternalServerError(HTTPException):
# class HTTPNotImplemented(HTTPException):
# class HTTPBadGateway(HTTPException):
# class ServiceUnavailable(HTTPException):
# class HTTPServiceUnavailable(ServiceUnavailable):
# class NoTokenLookupException(Exception):
# class EndpointNotFound(Exception):
# class StackFailure(Exception):
#     def __init__(self, message=None):
#     def __str__(self):
#     def __init__(self, message=None, code=None):
#     def __str__(self):
#     def __str__(self):
# def from_response(response):


# Path: heatclient/tests/unit/test_common_http.py
import socket
import six
import testtools
from unittest import mock
from keystoneauth1 import adapter
from oslo_serialization import jsonutils
from heatclient.common import http
from heatclient.common import utils
from heatclient import exc
from heatclient.tests.unit import fakes

                               'User-Agent': 'python-heatclient'}),
            mock.call('GET', 'http://example.com:8004',
                      allow_redirects=False,
                      headers={'Content-Type': 'application/json',
                               'Accept': 'application/json',
                               'User-Agent': 'python-heatclient'})
        ])

    def test_http_404_json_request(self, mock_request):
        # Record a 404
        mock_request.return_value = fakes.FakeHTTPResponse(
            404, 'OK', {'content-type': 'application/json'},
            '{}')
        client = http.HTTPClient('http://example.com:8004')
        e = self.assertRaises(exc.HTTPNotFound, client.json_request, 'GET', '')
        # Assert that the raised exception can be converted to string
        self.assertIsNotNone(str(e))
        mock_request.assert_called_with(
            'GET', 'http://example.com:8004',
            allow_redirects=False,
            headers={'Content-Type': 'application/json',
                     'Accept': 'application/json',
                     'User-Agent': 'python-heatclient'})

    def test_http_300_json_request(self, mock_request):
        # Record a 300
        mock_request.return_value = fakes.FakeHTTPResponse(
            300, 'OK', {'content-type': 'application/json'},
            '{}')
        # Assert that the raised exception can be converted to string

        client = http.HTTPClient('http://example.com:8004')