From 36001f6f536dc8379e67b3fe0602dba79a086a6c Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Tue, 10 Oct 2017 21:58:44 +0200 Subject: [PATCH] Start to deprecate HTTPServerOption --- http/vibe/http/proxy.d | 2 +- http/vibe/http/server.d | 75 +++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/http/vibe/http/proxy.d b/http/vibe/http/proxy.d index 2965c33fbc..5d03723544 100644 --- a/http/vibe/http/proxy.d +++ b/http/vibe/http/proxy.d @@ -34,7 +34,7 @@ import std.exception; void listenHTTPReverseProxy(HTTPServerSettings settings, HTTPReverseProxySettings proxy_settings) { // disable all advanced parsing in the server - settings.options = HTTPServerOption.None; + settings.options = HTTPServerOption.none; listenHTTP(settings, reverseProxyRequest(proxy_settings)); } /// ditto diff --git a/http/vibe/http/server.d b/http/vibe/http/server.d index 8d07a2a0a3..17221e4eff 100644 --- a/http/vibe/http/server.d +++ b/http/vibe/http/server.d @@ -530,20 +530,18 @@ alias HTTPServerErrorPageHandler = void delegate(HTTPServerRequest req, HTTPServ will also drain the `HTTPServerRequest.bodyReader` stream whenever a request body with form or JSON data is encountered. */ -enum HTTPServerOption { - none = 0, - /// Fills the `.path` and `.queryString` fields in the request - parseURL = 1<<0, - /// Deprecated: Fills the `.query` field in the request - parseQueryString = 1<<1 | parseURL, - /// Deprecated: Fills the `.form` field in the request - parseFormBody = 1<<2, - /// Deprecated: Fills the `.json` field in the request - parseJsonBody = 1<<3, - /// Deprecated: Fills the `.files` field of the request for "multipart/mixed" requests - parseMultiPartBody = 1<<4, - /// Deprecated: Fills the `.cookies` field in the request - parseCookies = 1<<5, +struct HTTPServerOption { + static enum none = 0; + deprecated("It is done lazy.") + static enum parseURL = 1<<0; + deprecated("It is done lazy.") + static enum parseQueryString = 1<<1; + deprecated("It is done lazy.") + static enum parseFormBody = 1<<2; + deprecated("It is done lazy.") + static enum parseJsonBody = 1<<3; + deprecated("It is done lazy.") + static enum parseMultiPartBody = 1<<4; /** Deprecated: Distributes request processing among worker threads Note that this functionality assumes that the request handler @@ -560,7 +558,8 @@ enum HTTPServerOption { is more robust and often faster. The `reusePort` option works the same way in this scenario. */ - distribute = 1<<6, + deprecated("Use runWorkerTaskDist or start threads separately.") + static enum distribute = 1<<6; /** Enables stack traces (`HTTPServerErrorInfo.debugMessage`). Note that generating the stack traces are generally a costly @@ -569,38 +568,34 @@ enum HTTPServerOption { the application, such as function addresses, which can help an attacker to abuse possible security holes. */ - errorStackTraces = 1<<7, + static enum errorStackTraces = 1<<7; /// Enable port reuse in `listenTCP()` - reusePort = 1<<8, + static enum reusePort = 1<<8; /** The default set of options. Includes all parsing options, as well as the `errorStackTraces` option if the code is compiled in debug mode. */ - defaults = - parseURL | - parseQueryString | - parseFormBody | - parseJsonBody | - parseMultiPartBody | - parseCookies | - () { debug return errorStackTraces; else return none; } (), - - /// deprecated - None = none, - /// deprecated - ParseURL = parseURL, - /// deprecated - ParseQueryString = parseQueryString, - /// deprecated - ParseFormBody = parseFormBody, - /// deprecated - ParseJsonBody = parseJsonBody, - /// deprecated - ParseMultiPartBody = parseMultiPartBody, - /// deprecated - ParseCookies = parseCookies + static enum defaults = () { debug return HTTPServerOption.errorStackTraces; else return HTTPServerOption.none; } ().HTTPServerOption; + + deprecated("None has been renamed to none.") + static enum None = none; + deprecated("It is done lazy.") + static enum ParseURL = none; + deprecated("It is done lazy.") + static enum ParseQueryString = none; + deprecated("It is done lazy.") + static enum ParseFormBody = none; + deprecated("It is done lazy.") + static enum ParseJsonBody = none; + deprecated("It is done lazy.") + static enum ParseMultiPartBody = none; + deprecated("It is done lazy.") + static enum ParseCookies = none; + + int x; + alias x this; }