mirror of
https://github.com/ysoftdevs/wapifuzz.git
synced 2026-01-13 15:13:29 +01:00
22 lines
509 B
Python
22 lines
509 B
Python
from http.client import HTTPResponse, HTTPException
|
|
from typing import Union
|
|
from io import BytesIO
|
|
|
|
|
|
class FakeSocket:
|
|
def __init__(self, response_str):
|
|
self._file = BytesIO(response_str)
|
|
|
|
def makefile(self, *args, **kwargs):
|
|
return self._file
|
|
|
|
|
|
def get_response_object(data) -> Union[HTTPResponse, None]:
|
|
try:
|
|
source = FakeSocket(data)
|
|
response = HTTPResponse(source)
|
|
response.begin()
|
|
return response
|
|
except HTTPException:
|
|
return None
|