]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
urldata: change 'keep_post' into three distinct bitfields
authorDaniel Stenberg <daniel@haxx.se>
Mon, 12 Jan 2026 10:07:01 +0000 (11:07 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 12 Jan 2026 15:20:14 +0000 (16:20 +0100)
Closes #20262

lib/http.c
lib/setopt.c
lib/urldata.h

index bea62ef5cd25fa2f38e464ebc371c0c537f2890c..0343aba3e7df096ba1c2dc067624b6968e728b04 100644 (file)
@@ -1413,7 +1413,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
     if((data->state.httpreq == HTTPREQ_POST ||
         data->state.httpreq == HTTPREQ_POST_FORM ||
         data->state.httpreq == HTTPREQ_POST_MIME) &&
-       !(data->set.keep_post & CURL_REDIR_POST_301)) {
+       !data->set.post301) {
       http_switch_to_get(data, 301);
       switch_to_get = TRUE;
     }
@@ -1438,7 +1438,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
     if((data->state.httpreq == HTTPREQ_POST ||
         data->state.httpreq == HTTPREQ_POST_FORM ||
         data->state.httpreq == HTTPREQ_POST_MIME) &&
-       !(data->set.keep_post & CURL_REDIR_POST_302)) {
+       !data->set.post302) {
       http_switch_to_get(data, 302);
       switch_to_get = TRUE;
     }
@@ -1454,7 +1454,7 @@ CURLcode Curl_http_follow(struct Curl_easy *data, const char *newurl,
        ((data->state.httpreq != HTTPREQ_POST &&
          data->state.httpreq != HTTPREQ_POST_FORM &&
          data->state.httpreq != HTTPREQ_POST_MIME) ||
-        !(data->set.keep_post & CURL_REDIR_POST_303))) {
+        !data->set.post303)) {
       http_switch_to_get(data, 303);
       switch_to_get = TRUE;
     }
index 62e19a05622886b6db7ab35965daba592459c63a..5ea3cbbb9bee80aabf4d202cf8fbeb798b1c8a87 100644 (file)
@@ -963,7 +963,9 @@ static CURLcode setopt_long(struct Curl_easy *data, CURLoption option,
       /* no return error on too high numbers since the bitmask could be
          extended in a future */
       return CURLE_BAD_FUNCTION_ARGUMENT;
-    s->keep_post = arg & CURL_REDIR_POST_ALL;
+    s->post301 = !!(arg & CURL_REDIR_POST_301);
+    s->post302 = !!(arg & CURL_REDIR_POST_302);
+    s->post303 = !!(arg & CURL_REDIR_POST_303);
     break;
 
   case CURLOPT_HEADEROPT:
index 564329d9d27c506816a03f617c3041bd8785e573..0517b9b2d069a7c5ca2f2b154ba6d851aeddd988 100644 (file)
@@ -1469,10 +1469,8 @@ struct UserDefined {
   */
   uint8_t ftp_create_missing_dirs;
 #endif
-  uint8_t use_ssl;   /* if AUTH TLS is to be attempted etc, for FTP or
-                              IMAP or POP3 or others! (type: curl_usessl)*/
-  char keep_post;     /* keep POSTs as POSTs after a 30x request; each
-                         bit represents a request, from 301 to 303 */
+  uint8_t use_ssl;   /* if AUTH TLS is to be attempted etc, for FTP or IMAP or
+                        POP3 or others! (type: curl_usessl)*/
   uint8_t timecondition; /* kind of time comparison: curl_TimeCond */
   uint8_t method;   /* what kind of HTTP request: Curl_HttpReq */
   uint8_t httpwant; /* when non-zero, a specific HTTP version requested
@@ -1587,6 +1585,9 @@ struct UserDefined {
   BIT(ws_raw_mode);
   BIT(ws_no_auto_pong);
 #endif
+  BIT(post301); /* keep POSTs as POSTs after a 301 request */
+  BIT(post302); /* keep POSTs as POSTs after a 302 request */
+  BIT(post303); /* keep POSTs as POSTs after a 303 request */
 };
 
 #ifndef CURL_DISABLE_MIME