-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
63 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,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: ... | ||
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: ... | ||
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. | ||
def batch_request(requests: List[Request], return_panic: bool = False) -> List[Union[Response, RuntimeError]]: ... | ||
Returns: | ||
List[Union[Response, RuntimeError]]: List of Response objects or errors. | ||
""" | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters