Files
django-stubs/django-stubs/http/response.pyi
Maxim Kurnikov 25a71a7ef5 some stubs
2018-12-06 19:04:06 +03:00

113 lines
4.0 KiB
Python

# Stubs for django.http.response (Python 3.5)
import datetime
from json import JSONEncoder
from typing import Any, Dict, Iterable, Iterator, List, Optional, overload, Tuple, Type, Union
from django.http.cookie import SimpleCookie
import six
class BadHeaderError(ValueError): ...
class HttpResponseBase(six.Iterator):
status_code = ... # type: int
cookies = ... # type: SimpleCookie
closed = ... # type: bool
reason_phrase = ... # type: str
charset = ... # type: str
def __init__(
self, content_type: str = None, status: int = None, reason: str = None, charset: str = None
) -> None: ...
def serialize_headers(self) -> bytes: ...
def __bytes__(self) -> bytes: ...
def __setitem__(self, header: str, value: Union[str, bytes]) -> None: ...
def __delitem__(self, header: str) -> None: ...
def __getitem__(self, header: str) -> str: ...
def has_header(self, header: str) -> bool: ...
def __contains__(self, item: object) -> bool: ...
def items(self) -> Iterable[Tuple[str, str]]: ...
@overload
def get(self, header: str, alternate: str) -> str: ...
@overload
def get(self, header: str) -> Optional[str]: ...
def set_cookie(
self,
key: str,
value: str = "",
max_age: int = None,
expires: Union[str, datetime.datetime] = None,
path: str = "",
domain: str = None,
secure: bool = False,
httponly: bool = False,
) -> None: ...
def setdefault(self, key: str, value: str) -> None: ...
def set_signed_cookie(self, key: str, value: str, salt: str = "", **kwargs: Any) -> None: ...
def delete_cookie(self, key: str, path: str = "", domain: str = None) -> None: ...
def make_bytes(self, value: object) -> bytes: ...
def close(self) -> None: ...
def write(self, content: object) -> None: ...
def flush(self) -> None: ...
def tell(self) -> int: ...
def readable(self) -> bool: ...
def seekable(self) -> bool: ...
def writable(self) -> bool: ...
def writelines(self, lines: Iterable[object]) -> None: ...
class HttpResponse(HttpResponseBase):
streaming = ... # type: bool
def __init__(self, content: object = b"", *args: Any, **kwargs: Any) -> None: ...
def serialize(self) -> bytes: ...
@property
def content(self) -> bytes: ...
@content.setter
def content(self, value: Any) -> None: ...
def __iter__(self) -> Iterator[bytes]: ...
def getvalue(self) -> bytes: ...
class StreamingHttpResponse(HttpResponseBase):
def __init__(self, streaming_content: Iterable[bytes] = ..., *args: Any, **kwargs: Any) -> None: ...
@property
def content(self) -> bytes: ...
@property
def streaming_content(self) -> Iterator[bytes]: ...
@streaming_content.setter
def streaming_content(self, value: Iterable[bytes]) -> None: ...
def __iter__(self) -> Iterator[bytes]: ...
def getvalue(self) -> bytes: ...
class FileResponse(StreamingHttpResponse): ...
class HttpResponseRedirectBase(HttpResponse):
allowed_schemes = ... # type: List[str]
def __init__(self, redirect_to: str, *args: Any, **kwargs: Any) -> None: ...
@property
def url(self) -> str: ...
class HttpResponseRedirect(HttpResponseRedirectBase): ...
class HttpResponsePermanentRedirect(HttpResponseRedirectBase): ...
class HttpResponseNotModified(HttpResponse):
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
class HttpResponseBadRequest(HttpResponse): ...
class HttpResponseNotFound(HttpResponse): ...
class HttpResponseForbidden(HttpResponse): ...
class HttpResponseNotAllowed(HttpResponse):
def __init__(self, permitted_methods: Iterable[str], *args: Any, **kwargs: Any) -> None: ...
class HttpResponseGone(HttpResponse): ...
class HttpResponseServerError(HttpResponse): ...
class Http404(Exception): ...
class JsonResponse(HttpResponse):
def __init__(
self,
data: object,
encoder: Type[JSONEncoder] = ...,
safe: bool = True,
json_dumps_params: Dict[str, Any] = None,
**kwargs: Any
) -> None: ...