]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Only switch ctx->state after we've received all the header lines for a header. Fixes...
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 24 Jul 2017 16:33:58 +0000 (12:33 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 24 Jul 2017 16:35:10 +0000 (12:35 -0400)
src/modules/rlm_rest/rest.c

index 918ca09eb047cb7cb7c37a79075ae4259bacdc8a..8df8dbb3b9531d99b1348a44690e37062873416f 100644 (file)
@@ -1546,11 +1546,21 @@ static size_t rest_response_header(void *in, size_t size, size_t nmemb, void *us
        http_body_type_t type;
 
        /*
-        *  Curl seems to throw these (\r\n) in before the next set of headers when
-        *  looks like it's just a body separator and safe to ignore after we
-        *  receive a 100 Continue.
+        *  This seems to be curl's indication there are no more header lines.
         */
-       if (t == 2 && ((p[0] == '\r') && (p[1] == '\n'))) return t;
+       if (t == 2 && ((p[0] == '\r') && (p[1] == '\n'))) {
+               /*
+                *  If we got a 100 Continue, we need to send additional payload data.
+                *  reset the state to WRITE_STATE_INIT, so that when were called again
+                *  we overwrite previous header data with that from the proper header.
+                */
+               if (ctx->code == 100) {
+                       RDEBUG2("Continuing...");
+                       ctx->state = WRITE_STATE_INIT;
+               }
+
+               return t;
+       }
 
        switch (ctx->state) {
        case WRITE_STATE_INIT:
@@ -1698,16 +1708,6 @@ static size_t rest_response_header(void *in, size_t size, size_t nmemb, void *us
                break;
        }
 
-       /*
-        *  If we got a 100 Continue, we need to send additional payload data.
-        *  reset the state to WRITE_STATE_INIT, so that when were called again
-        *  we overwrite previous header data with that from the proper header.
-        */
-       if (ctx->code == 100) {
-               RDEBUG2("Continuing...");
-               ctx->state = WRITE_STATE_INIT;
-       }
-
        return t;
 
 malformed: