Bug#1041686: Add support for HTTP Status Code 308 as described in RFC 7238 (with patch)

2023-07-23 Thread Thomas Dickey
On Sat, Jul 22, 2023 at 09:05:17AM +0200, Joey Schulze wrote:
> Package: lynx
> Version: 2.9.0dev.12-1
> Severity: wishlist
> Tags: patch upstream
> X-Debbugs-Cc: j...@infodrom.org
> 
> Hi,
> 
> please add support for HTTP Status Code 308 (Permanent Redirect) to
> lynx, at least for the request method GET.  This new code has been
> specified in RFC 7238 in 2014.
> 
> Attached please find a patch for the quilt system which can be easily
> integrated.

The patch duplicates the check for 301 as 308 (including copying a comment
by "FM", who's not been active for about 25 years.  I'm assuming that
modifying the if-statement for 301 would be what you had in mind.

-- 
Thomas E. Dickey 
https://invisible-island.net


signature.asc
Description: PGP signature


Bug#1041686: Add support for HTTP Status Code 308 as described in RFC 7238 (with patch)

2023-07-22 Thread Joey Schulze
Package: lynx
Version: 2.9.0dev.12-1
Severity: wishlist
Tags: patch upstream
X-Debbugs-Cc: j...@infodrom.org

Hi,

please add support for HTTP Status Code 308 (Permanent Redirect) to
lynx, at least for the request method GET.  This new code has been
specified in RFC 7238 in 2014.

Attached please find a patch for the quilt system which can be easily
integrated.

Please also forward it to the upstream project.

Regards

Joey
Support HTTP Status Code 308 Permanent Redirect

Code 308 does not allow switching from POST to GET protocol,
thus aborting when doing POST requests.

Index: lynx-2.9.0dev.12/WWW/Library/Implementation/HTTP.c
===
--- lynx-2.9.0dev.12.orig/WWW/Library/Implementation/HTTP.c
+++ lynx-2.9.0dev.12/WWW/Library/Implementation/HTTP.c
@@ -2213,7 +2213,8 @@ static int HTLoadHTTP(const char *arg,
 * 305 Use Proxy.
 * 306 Set Proxy.
 * 307 Temporary Redirect with method retained.
-* > 308 is unknown.
+* 308 Permanent Redirect
+* > 309 is unknown.
 */
if (no_url_redirection || do_head || keep_mime_headers) {
/*
@@ -2267,7 +2268,7 @@ static int HTLoadHTTP(const char *arg,
 
if (server_status == 305 ||
server_status == 306 ||
-   server_status > 307) {
+   server_status > 308) {
/*
 * Show user the content, if any, for 305, 306, or unknown
 * status.  - FM
@@ -2341,6 +2342,19 @@ static int HTLoadHTTP(const char *arg,
HTAlert(gettext("Have POST content.  Treating 
Permanent Redirection as Temporary.\n"));
} else {
permanent_redirection = TRUE;
+   }
+   }
+   if (server_status == 308) { /* Permanent Redirect */
+   if (do_post) {
+   /*
+* Don't make the redirection permanent if we have
+* POST content.  - FM
+*/
+   CTRACE((tfp,
+   "HTTP: Have POST content.  Treating 308 
(Permanent) as Temporary.\n"));
+   HTAlert(gettext("Have POST content.  Treating 
Permanent Redirection as Temporary.\n"));
+   } else {
+   permanent_redirection = TRUE;
}
}
doing_redirect = TRUE;