mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement POST and headers
This commit is contained in:
parent
71e8654c80
commit
6d4d11dc9e
@ -18,6 +18,11 @@
|
||||
console.log(msg);
|
||||
}
|
||||
|
||||
function base64_to_bytes(base64) {
|
||||
const bin_string = atob(base64);
|
||||
return Uint8Array.from(bin_string, (m) => m.codePointAt(0));
|
||||
}
|
||||
|
||||
function notify_that_messages_are_available() {
|
||||
send_msg({type: 'messages_available', count: messages.length});
|
||||
}
|
||||
@ -49,6 +54,14 @@
|
||||
method: req.method.toUpperCase(),
|
||||
signal: controller.signal,
|
||||
};
|
||||
if (data && data.length > 0) fetch_options.body = base64_to_bytes(data);
|
||||
if (req.headers) {
|
||||
const headers = new Headers();
|
||||
for (const p of req.headers) {
|
||||
headers.append(p[0], p[1]);
|
||||
}
|
||||
fetch_options.headers = headers;
|
||||
}
|
||||
const response = await fetch(req.url, fetch_options);
|
||||
var headers = [];
|
||||
for (const pair of response.headers) {
|
||||
|
@ -250,9 +250,6 @@ class Browser:
|
||||
|
||||
class WebEngineBrowser(Browser):
|
||||
|
||||
def is_method_ok(self, method: str) -> bool:
|
||||
return method.upper() in ('GET', 'POST')
|
||||
|
||||
def run_worker(self) -> subprocess.Popen:
|
||||
return run_worker(self.tdir, self.user_agent, self.verify_ssl_certificates, function='webengine_worker')
|
||||
|
||||
|
@ -104,7 +104,6 @@ class Worker(QWebEnginePage):
|
||||
|
||||
def start_download(self, output_dir: str, req: Request, data: str) -> DownloadRequest:
|
||||
filename = os.path.basename(req['filename'])
|
||||
# TODO: Implement POST requests with data
|
||||
payload = json.dumps({'req': req, 'data': data})
|
||||
content = f'''<!DOCTYPE html>
|
||||
<html><head></head></body><div id="payload">{html.escape(payload)}</div></body></html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user