You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/04/07 11:44:26 UTC

[incubator-nuttx-apps] 02/02: webclient: 304 and 305 are not really redirects

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit 2d0a174cecd0ad606d4d0d1b3767ca2f9580fead
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Wed Apr 7 10:59:28 2021 +0900

    webclient: 304 and 305 are not really redirects
    
    Eg. The docker API sometimes returns 304 even for requests without etags.
    https://docs.docker.com/engine/api/v1.40/#operation/ContainerStop
---
 netutils/webclient/webclient.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/netutils/webclient/webclient.c b/netutils/webclient/webclient.c
index abed026..1379d8e 100644
--- a/netutils/webclient/webclient.c
+++ b/netutils/webclient/webclient.c
@@ -423,9 +423,15 @@ static inline int wget_parsestatus(struct webclient_context *ctx,
 
               /* Check for 3xx (Redirection)
                * Location: header line will contain the new location.
+               *
+               * Note: the following 3xx are not redirects.
+               *   304 not modified
+               *   305 use proxy
                */
 
-              else if ((http_status / 100) == 3)
+              else if ((http_status / 100) == 3 &&
+                       (http_status != 304) &&
+                       (http_status != 305))
                 {
                   ws->httpstatus = HTTPSTATUS_MOVED;
                 }