-
Notifications
You must be signed in to change notification settings - Fork 0
/
batch_http_request.pyi
66 lines (55 loc) · 2.12 KB
/
batch_http_request.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from typing import List, Tuple, Optional, Union
class Request:
"""
Represents an HTTP request.
Attributes:
url (str): The URL to which the request is sent.
method (str): HTTP method (e.g., GET, POST).
headers (List[Tuple[str, str]]): List of headers as key-value pairs.
body (Optional[bytes]): Optional body of the request, in bytes.
"""
url: str
method: str
headers: List[Tuple[str, str]]
body: Optional[bytes]
def __init__(self, url: str, method: str, headers: Optional[List[Tuple[str, str]]] = [], body: Optional[bytes] = None) -> None:
"""
Initializes a Request object.
Args:
url (str): The URL for the request.
method (str): The HTTP method to use.
headers (Optional[List[Tuple[str, str]]]): Optional list of headers.
body (Optional[bytes]): Optional request body.
"""
...
class Response:
"""
Represents an HTTP response.
Attributes:
status_code (int): HTTP status code of the response.
headers (List[Tuple[str, str]]): List of headers as key-value pairs.
body (bytes): Body of the response, in bytes.
"""
status_code: int
headers: List[Tuple[str, str]]
body: bytes
def __init__(self, status_code: int, headers: List[Tuple[str, str]], body: bytes) -> None:
"""
Initializes a Response object.
Args:
status_code (int): The HTTP status code.
headers (List[Tuple[str, str]]): List of headers.
body (bytes): The response body.
"""
...
def batch_request(requests: List[Request], return_panic: bool = False, proxy: List[Tuple[str, str]] = []) -> List[Union[Response, RuntimeError]]:
"""
Handles a batch of HTTP requests.
Args:
requests (List[Request]): List of Request objects.
return_panic (bool): If True, include errors in the response list.
proxy (List[Tuple[str, str]]): Optional list of proxy settings as key-value pairs.
Returns:
List[Union[Response, RuntimeError]]: List of Response objects or errors.
"""
...