From 8bbdcbca728de93d4249f9569d56c008e07f73d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi
Date: Mon, 20 Feb 2023 11:37:36 +0200
Subject: [PATCH 1/1] Handling inline media redirects
IssueID #578
res/about/version.gmi | 3 +++
src/gmrequest.c | 4 ++++
src/gmrequest.h | 1 +
src/media.c | 13 +++++++++++++
src/media.h | 2 ++
src/ui/documentwidget.c | 13 +++++++++++++
6 files changed, 36 insertions(+)
diff --git a/res/about/version.gmi b/res/about/version.gmi
index 8c88c024..0a430b58 100644
--- a/res/about/version.gmi
+++ b/res/about/version.gmi
@@ -6,6 +6,9 @@
+## 1.15.3
+* Fixed handling of redirects in the inline media player and file downloader.
diff --git a/src/gmrequest.c b/src/gmrequest.c
index aaee50c0..3fe638d2 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -1142,6 +1142,10 @@ iBool isFinished_GmRequest(const iGmRequest *d) {
return iTrue;
}
+iBool filtersEnabled_GmRequest(const iGmRequest *d) {
+}
enum iGmStatusCode status_GmRequest(const iGmRequest *d) {
if (d) {
enum iGmStatusCode code;
diff --git a/src/gmrequest.h b/src/gmrequest.h
index 1ad4b7f3..634a7b62 100644
--- a/src/gmrequest.h
+++ b/src/gmrequest.h
@@ -83,6 +83,7 @@ void unlockResponse_GmRequest (iGmRequest *);
uint32_t id_GmRequest (const iGmRequest ); / unique ID */
iBool isFinished_GmRequest (const iGmRequest *);
+iBool filtersEnabled_GmRequest (const iGmRequest *);
enum iGmStatusCode status_GmRequest (const iGmRequest *);
const iString * meta_GmRequest (const iGmRequest *);
const iBlock * body_GmRequest (const iGmRequest *);
diff --git a/src/media.c b/src/media.c
index 57f126a2..f9ac0a2d 100644
--- a/src/media.c
+++ b/src/media.c
@@ -641,6 +641,19 @@ void deinit_MediaRequest(iMediaRequest *d) {
iRelease(d->req);
}
+void resubmitWithUrl_MediaRequest(iMediaRequest *d, const iString *url) {
+}
iMediaRequest *newReused_MediaRequest(iDocumentWidget *doc, unsigned int linkId,
iGmRequest *request) {
iMediaRequest *d = new_Object(&Class_MediaRequest);
diff --git a/src/media.h b/src/media.h
index 73ea9d83..0a818ec9 100644
--- a/src/media.h
+++ b/src/media.h
@@ -124,5 +124,7 @@ struct Impl_MediaRequest {
iDeclareObjectConstructionArgs(MediaRequest, iDocumentWidget *doc, unsigned int linkId,
const iString *url, iBool enableFilters)
+void resubmitWithUrl_MediaRequest (iMediaRequest *, const iString *url);
iMediaRequest * newReused_MediaRequest (iDocumentWidget *doc, unsigned int linkId,
iGmRequest *request);
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 6fdac976..6e73a891 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -3741,6 +3741,19 @@ static iBool handleMediaCommand_DocumentWidget_(iDocumentWidget *d, const char *
refresh_Widget(as_Widget(d));
}
}
else if (category_GmStatusCode(code) == categoryRedirect_GmStatusCode) {
if (d->redirectCount++ < 5) {
/* Redo the request. */
iString *url = copy_String(meta_GmRequest(req->req));
resubmitWithUrl_MediaRequest(req, url);
delete_String(url);
}
else {
const iGmError *err = get_GmError(tooManyRedirects_GmStatusCode);
makeSimpleMessage_Widget(format_CStr(uiTextCaution_ColorEscape "%s", err->title), err->info);
removeMediaRequest_DocumentWidget_(d, req->linkId);
}
}
else {
const iGmError *err = get_GmError(code);
makeSimpleMessage_Widget(format_CStr(uiTextCaution_ColorEscape "%s", err->title), err->info);
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).