Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asLowerCase and lazy splitter for small part of header processing #2138

Merged
merged 2 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions http/vibe/http/common.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import std.format;
import std.range : isOutputRange;
import std.string;
import std.typecons;
import std.uni: asLowerCase;


enum HTTPVersion {
Expand Down Expand Up @@ -259,10 +260,10 @@ class HTTPRequest {
auto ph = "connection" in headers;
switch(httpVersion) {
case HTTPVersion.HTTP_1_0:
if (ph && toLower(*ph) == "keep-alive") return true;
if (ph && asLowerCase(*ph).equal("keep-alive")) return true;
return false;
case HTTPVersion.HTTP_1_1:
if (ph && toLower(*ph) != "keep-alive") return false;
if (ph && !(asLowerCase(*ph).equal("keep-alive"))) return false;
return true;
default:
return false;
Expand Down
10 changes: 6 additions & 4 deletions http/vibe/http/websockets.d
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import vibe.core.connectionpool;
import vibe.utils.array;

import core.time;
import std.algorithm: equal, splitter;
import std.array;
import std.base64;
import std.conv;
Expand All @@ -51,6 +52,7 @@ import std.functional;
import std.uuid;
import std.base64;
import std.digest.sha;
import std.uni: asLowerCase;
import vibe.crypto.cryptorand;

@safe:
Expand Down Expand Up @@ -203,9 +205,9 @@ void handleWebSocket(scope WebSocketHandshakeDelegate on_handshake, scope HTTPSe
auto isUpgrade = false;

if( pConnection ) {
auto connectionTypes = split(*pConnection, ",");
auto connectionTypes = splitter(*pConnection, ",");
foreach( t ; connectionTypes ) {
if( t.strip().toLower() == "upgrade" ) {
if( t.strip().asLowerCase().equal("upgrade") ) {
isUpgrade = true;
break;
}
Expand Down Expand Up @@ -282,9 +284,9 @@ HTTPServerRequestDelegateS handleWebSockets(WebSocketHandshakeDelegate on_handsh
auto isUpgrade = false;

if( pConnection ) {
auto connectionTypes = split(*pConnection, ",");
auto connectionTypes = splitter(*pConnection, ",");
foreach( t ; connectionTypes ) {
if( t.strip().toLower() == "upgrade" ) {
if( t.strip().asLowerCase().equal("upgrade") ) {
isUpgrade = true;
break;
}
Expand Down