Skip to content

Commit 42936f8

Browse files
committed
improve code a little, get rid of templates and contexts
1 parent 1bd4386 commit 42936f8

File tree

8 files changed

+462
-458
lines changed

8 files changed

+462
-458
lines changed

ydb/library/actors/http/http.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ TUrlParameters THttpRequest::GetParameters() const {
8181
}
8282

8383
template <>
84-
bool THttpParser<THttpRequest, TSocketBuffer>::HasBody() const {
84+
bool THttpParser<THttpRequest>::HasBody() const {
8585
if (!Body.empty()) {
8686
return true;
8787
}
8888
return !ContentLength.empty() || !TransferEncoding.empty();
8989
}
9090

9191
template <>
92-
void THttpParser<THttpRequest, TSocketBuffer>::Advance(size_t len) {
92+
void THttpParser<THttpRequest>::Advance(size_t len) {
9393
TStringBuf data(Pos(), len);
9494
while (!data.empty()) {
9595
if (Stage != EParseStage::Error) {
@@ -224,25 +224,25 @@ void THttpParser<THttpRequest, TSocketBuffer>::Advance(size_t len) {
224224
}
225225

226226
template <>
227-
THttpParser<THttpRequest, TSocketBuffer>::EParseStage THttpParser<THttpRequest, TSocketBuffer>::GetInitialStage() {
227+
THttpParser<THttpRequest>::EParseStage THttpParser<THttpRequest>::GetInitialStage() {
228228
return EParseStage::Method;
229229
}
230230

231231
template <>
232-
bool THttpParser<THttpResponse, TSocketBuffer>::ExpectedBody() const {
232+
bool THttpParser<THttpResponse>::ExpectedBody() const {
233233
return !Status.starts_with("1") && Status != "204" && Status != "304";
234234
}
235235

236236
template <>
237-
bool THttpParser<THttpResponse, TSocketBuffer>::HasBody() const {
237+
bool THttpParser<THttpResponse>::HasBody() const {
238238
if (!Body.empty()) {
239239
return true;
240240
}
241241
return ExpectedBody() && (!ContentType.empty() || !ContentLength.empty() || !TransferEncoding.empty());
242242
}
243243

244244
template <>
245-
THttpParser<THttpResponse, TSocketBuffer>::EParseStage THttpParser<THttpResponse, TSocketBuffer>::GetInitialStage() {
245+
THttpParser<THttpResponse>::EParseStage THttpParser<THttpResponse>::GetInitialStage() {
246246
return EParseStage::Protocol;
247247
}
248248

@@ -253,7 +253,7 @@ void THttpResponse::Clear() {
253253
}
254254

255255
template <>
256-
void THttpParser<THttpResponse, TSocketBuffer>::Advance(size_t len) {
256+
void THttpParser<THttpResponse>::Advance(size_t len) {
257257
TStringBuf data(Pos(), len);
258258
while (!data.empty()) {
259259
if (Stage != EParseStage::Error) {
@@ -398,7 +398,7 @@ void THttpParser<THttpResponse, TSocketBuffer>::Advance(size_t len) {
398398
}
399399

400400
template <>
401-
void THttpParser<THttpResponse, TSocketBuffer>::ConnectionClosed() {
401+
void THttpParser<THttpResponse>::ConnectionClosed() {
402402
if (Stage == EParseStage::Done) {
403403
return;
404404
}
@@ -412,7 +412,7 @@ void THttpParser<THttpResponse, TSocketBuffer>::ConnectionClosed() {
412412
}
413413

414414
THttpOutgoingResponsePtr THttpIncomingRequest::CreateResponseString(TStringBuf data) {
415-
THttpParser<THttpResponse, TSocketBuffer> parser(data);
415+
THttpParser<THttpResponse> parser(data);
416416
THeadersBuilder headers(parser.Headers);
417417
if (!Endpoint->WorkerName.empty()) {
418418
headers.Set("X-Worker-Name", Endpoint->WorkerName);
@@ -654,7 +654,7 @@ void THttpOutgoingResponse::AddDataChunk(THttpOutgoingDataChunkPtr dataChunk) {
654654
}
655655

656656
THttpOutgoingDataChunk::THttpOutgoingDataChunk(THttpOutgoingResponsePtr response, TStringBuf data)
657-
: THttpDataChunk<TSocketBuffer>(data)
657+
: THttpDataChunk(data)
658658
, Response(std::move(response))
659659
{}
660660

0 commit comments

Comments
 (0)