Skip to content

Commit

Permalink
Start to deprecate HTTPServerOption
Browse files Browse the repository at this point in the history
  • Loading branch information
wilzbach committed Oct 10, 2017
1 parent 714e6bc commit 36001f6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 41 deletions.
2 changes: 1 addition & 1 deletion http/vibe/http/proxy.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
75 changes: 35 additions & 40 deletions http/vibe/http/server.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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;
}


Expand Down

0 comments on commit 36001f6

Please sign in to comment.