This commit is contained in:
parent
2587d705fc
commit
9452197f23
@ -7,7 +7,7 @@ steps:
|
|||||||
image: python
|
image: python
|
||||||
commands:
|
commands:
|
||||||
- pip install flake8
|
- pip install flake8
|
||||||
- flake8 pynyaata --ignore=E501
|
- flake8 pynyaata
|
||||||
- name: docker
|
- name: docker
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
|
@ -5,9 +5,9 @@ from .config import CLOUDPROXY_ENDPOINT
|
|||||||
|
|
||||||
|
|
||||||
class FlareRequests(Session):
|
class FlareRequests(Session):
|
||||||
def request(self, method, url, params=None, **kwargs):
|
def request(self, method, url, params=None, data=None, **kwargs):
|
||||||
if not CLOUDPROXY_ENDPOINT:
|
if not CLOUDPROXY_ENDPOINT:
|
||||||
return super().request(method, url, params, **kwargs)
|
return super().request(method, url, params, data, **kwargs)
|
||||||
|
|
||||||
sessions = post(CLOUDPROXY_ENDPOINT, json={"cmd": "sessions.list"}).json()
|
sessions = post(CLOUDPROXY_ENDPOINT, json={"cmd": "sessions.list"}).json()
|
||||||
|
|
||||||
@ -22,14 +22,18 @@ class FlareRequests(Session):
|
|||||||
else:
|
else:
|
||||||
raise RequestException(response)
|
raise RequestException(response)
|
||||||
|
|
||||||
|
if params:
|
||||||
|
url += "&" if len(url.split("?")) > 1 else "?"
|
||||||
|
url = f"{url}{parse.urlencode(params)}"
|
||||||
|
|
||||||
post_data = {
|
post_data = {
|
||||||
"cmd": f"request.{method.lower()}",
|
"cmd": f"request.{method.lower()}",
|
||||||
"session": FLARESESSION,
|
"session": FLARESESSION,
|
||||||
"url": url,
|
"url": url,
|
||||||
}
|
}
|
||||||
|
|
||||||
if params:
|
if data:
|
||||||
post_data["postData"] = parse.urlencode(params)
|
post_data["postData"] = parse.urlencode(data)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = post(
|
response = post(
|
||||||
@ -40,12 +44,22 @@ class FlareRequests(Session):
|
|||||||
solution = response.json()
|
solution = response.json()
|
||||||
|
|
||||||
if "solution" in solution:
|
if "solution" in solution:
|
||||||
|
if "content-type" in solution["solution"]["headers"]:
|
||||||
|
content_type = solution["solution"]["headers"][
|
||||||
|
"content-type"
|
||||||
|
].split(";")
|
||||||
|
if len(content_type) > 1:
|
||||||
|
charset = content_type[1].split("=")
|
||||||
|
if len(charset) > 1:
|
||||||
|
encoding = charset[1]
|
||||||
|
|
||||||
resolved = Response()
|
resolved = Response()
|
||||||
|
|
||||||
resolved.raw = BytesIO(solution["solution"]["response"].encode())
|
|
||||||
resolved.status_code = solution["solution"]["status"]
|
resolved.status_code = solution["solution"]["status"]
|
||||||
resolved.headers = solution["solution"]["headers"]
|
resolved.headers = solution["solution"]["headers"]
|
||||||
|
resolved.raw = BytesIO(solution["solution"]["response"].encode())
|
||||||
resolved.url = url
|
resolved.url = url
|
||||||
|
resolved.encoding = encoding or None
|
||||||
resolved.reason = solution["status"]
|
resolved.reason = solution["status"]
|
||||||
resolved.cookies = solution["solution"]["cookies"]
|
resolved.cookies = solution["solution"]["cookies"]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user