from typing import Dict, Optional, Union


class HttpRequest(object):
    def __init__(self, url, method, query=None, headers=None, body=None):
        # type: (str, str, Optional[Dict[str, str]], Optional[Dict[str, str]], Optional[Union[bytes, str]]) -> None
        self.url = url
        self.method = method
        self.query = query if query is not None else {}
        self.headers = headers if headers is not None else {}
        self.body = body
        if isinstance(body, str):
            self.body = body.encode("utf-8")

    def __repr__(self):
        return 'HttpRequest(url = "{}", method = "{}", headers = "{}", body = "{}")'.format(self.url,
                                                                                            self.method,
                                                                                            self.headers,
                                                                                            self.body)

    def __str__(self):
        return self.__repr__()
