Skip to content

Commit 9ca07e9

Browse files
committed
The protocol upgrade can be set.
1 parent 096226f commit 9ca07e9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

source/hunt/http/server/Http1ServerRequestHandler.d

+4
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ class Http1ServerRequestHandler : HttpRequestParsingHandler {
9999
}
100100

101101
override bool messageComplete() {
102+
if(!_options.canUpgrade()) {
103+
return true;
104+
}
105+
102106
try {
103107
if (connection.getUpgradeHttp2Complete() || connection.getUpgradeWebSocketComplete()) {
104108
return true;

source/hunt/http/server/HttpServerOptions.d

+11-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class HttpServerOptions : HttpOptions {
2222
private NetServerOptions _netServerOptions;
2323
private HttpRequestOptions _httpRequestOptions;
2424
private ClientAuth clientAuth;
25+
private bool _canUpgrade = true;
2526

2627
this() {
2728
NetServerOptions netOptions = new NetServerOptions();
@@ -103,7 +104,16 @@ class HttpServerOptions : HttpOptions {
103104
HttpServerOptions setClientAuth(ClientAuth clientAuth) {
104105
this.clientAuth = clientAuth;
105106
return this;
106-
}
107+
}
108+
109+
bool canUpgrade() {
110+
return _canUpgrade;
111+
}
112+
113+
HttpServerOptions canUpgrade(bool value) {
114+
_canUpgrade = value;
115+
return this;
116+
}
107117

108118
/* ------------------------------ Session APIs ------------------------------ */
109119

0 commit comments

Comments
 (0)