Skip to content

Commit

Permalink
Add a setting for HTTP Upgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
Heromyth committed Mar 3, 2022
1 parent 92717b4 commit 46a624b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion source/hunt/framework/config/ApplicationConfig.d
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import std.socket : Address, parseAddress;
import std.string;

import hunt.http.MultipartOptions;
import hunt.logging.ConsoleLogger;
import hunt.logging.Logger;
import hunt.util.Configuration;


Expand Down Expand Up @@ -106,6 +106,7 @@ class ApplicationConfig {
size_t keepAliveTimeOut = 30;
size_t maxHeaderSize = 60 * 1024;
int cacheControl;
bool canUpgrade = true;
bool enableCors = false; // CORS support
string allowOrigin = "*";
string allowMethods = "*";
Expand Down
2 changes: 2 additions & 0 deletions source/hunt/framework/controller/Controller.d
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ abstract class Controller
}

HttpConnection httpConnection = context.httpConnection();
if(httpConnection is null)
throw new Error("The http connection is null!");

_request = new Request(context.getRequest(),
httpConnection.getRemoteAddress(),
Expand Down
3 changes: 2 additions & 1 deletion source/hunt/framework/provider/HttpServiceProvider.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import hunt.http.server.WebSocketHandler;
import hunt.http.WebSocketPolicy;
import hunt.http.WebSocketCommon;

import hunt.logging.ConsoleLogger;
import hunt.logging.Logger;

import poodinis;

Expand Down Expand Up @@ -62,6 +62,7 @@ class HttpServiceProvider : ServiceProvider {
.maxRequestSize(cast(int)appConfig.http.maxHeaderSize)
.maxFileSize(cast(int)appConfig.upload.maxSize)
.ioThreadSize(appConfig.http.ioThreads)
.canUpgrade(appConfig.http.canUpgrade)
.resourceCacheTime(staticFilesConfig.cacheTime.seconds);

version(WITH_HUNT_TRACE) {
Expand Down

0 comments on commit 46a624b

Please sign in to comment.