ah: reuse at end of transaction has no timeout
[platform/upstream/libwebsockets.git] / lib / server.c
index bed3d27..6e7c8b0 100644 (file)
@@ -1889,8 +1889,17 @@ lws_http_transaction_completed(struct lws *wsi)
                                return 1;
                        }
 #endif
-               } else
+               } else {
                        lws_header_table_reset(wsi, 1);
+                       /*
+                        * If we kept the ah, we should restrict the amount
+                        * of time we are willing to keep it.  Otherwise it
+                        * will be bound the whole time the connection remains
+                        * open.
+                        */
+                       lws_set_timeout(wsi, PENDING_TIMEOUT_HOLDING_AH,
+                                       wsi->vhost->keepalive_timeout);
+               }
        }
 
        /* If we're (re)starting on headers, need other implied init */
@@ -2619,13 +2628,17 @@ lws_serve_http_file(struct lws *wsi, const char *file, const char *content_type,
                lwsl_info("file is being provided in gzip\n");
        }
 
+       if (
 #if defined(LWS_WITH_RANGES)
-       if (ranges < 2 && content_type && content_type[0])
+           ranges < 2 &&
+#endif
+           content_type && content_type[0])
                if (lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_CONTENT_TYPE,
                                                 (unsigned char *)content_type,
                                                 strlen(content_type), &p, end))
                        return -1;
 
+#if defined(LWS_WITH_RANGES)
        if (ranges >= 2) { /* multipart byteranges */
                strncpy(wsi->u.http.multipart_content_type, content_type,
                        sizeof(wsi->u.http.multipart_content_type) - 1);