from typing import Optional, Dict, Tuple
from http.cookies import Morsel, SimpleCookie, CookieError
from urllib.parse import unquote, quote
from enum import Enum
from typing import NamedTuple


mimetypes: Dict = ...
hop_by_hop_headers: Tuple = ...
http_methods: Tuple = ...


class UploadedFile:
    filename: str
    value: bytes
    def __init__(self, upfile) -> None: ...


class HttpStatus(Enum):
    class Status(NamedTuple):
        code: int
        reason: str

    @staticmethod
    def of(code: int) -> 'HttpStatus': ...

    OK: Status = ...
    Created: Status = ...
    Accepted: Status = ...
    NoContent: Status = ...
    MovedPermanently: Status = ...
    Found: Status = ...
    SeeOther: Status = ...
    NotModified: Status = ...
    TemporaryRedirect: Status = ...
    BadRequest: Status = ...
    Unauthorized: Status = ...
    Forbidden: Status = ...
    NotFound: Status = ...
    MethodNotAllowed: Status = ...
    NotAcceptable: Status = ...
    Conflict: Status = ...
    Gone: Status = ...
    PreconditionFailed: Status = ...
    UnsupportedMediaType: Status = ...
    UnprocessableEntity: Status = ...
    UnavailableForLegalReasons: Status = ...
    InternalServerError: Status = ...


class Cookie:
    name: str
    value: str
    expires: Optional[int]
    path: str
    domain: Optional[str]
    secure: bool
    httponly: bool

    def __init__(self, name:str, value:str, expires:int=None, path:str='/',
                 domain:str=None, secure:bool=False, httponly:bool=False) -> None: ...
    def dumps(self) -> str: ...


def parse_cookie(http_cookie)->Dict[str, str]: ...


# lessweb framework exceptions
class NeedParamError(Exception):
    def __init__(self, query: str, doc: str) -> None: ...
    def __repr__(self): ...
    def __str__(self): ...


class BadParamError(Exception):
    def __init__(self, query: str, error: str) -> None: ...
    def __repr__(self): ...
    def __str__(self): ...


class NotFoundError(Exception):
    def __init__(self, methods=None) -> None: ...
    def __repr__(self): ...
    def __str__(self): ...


def header_name_of_wsgi_key(wsgi_key) -> str: ...
def wsgi_key_of_header_name(header_name) -> str: ...
