@@ -614,7 +614,7 @@ struct HttpParser {
614614 }
615615
616616public:
617- std::pair<unsigned int , void *> consumePostPadded (char *data, unsigned int length, void *user, void *reserved, MoveOnlyFunction<void *(void *, HttpRequest *)> &&requestHandler, MoveOnlyFunction<void *(void *, std::string_view, bool )> &&dataHandler, MoveOnlyFunction<void(HttpRequest *, unsigned int )> &&errorHandler = nullptr ) {
617+ std::pair<unsigned int , void *> consumePostPadded (char *data, unsigned int length, void *user, void *reserved, MoveOnlyFunction<void *(void *, HttpRequest *)> &&requestHandler, MoveOnlyFunction<void *(void *, std::string_view, bool )> &&dataHandler, MoveOnlyFunction<void(HttpRequest *, unsigned int )> &&errorHandler) {
618618
619619 /* This resets BloomFilter by construction, but later we also reset it again.
620620 * Optimize this to skip resetting twice (req could be made global) */
@@ -629,9 +629,7 @@ struct HttpParser {
629629 dataHandler (user, chunk, chunk.length () == 0 );
630630 }
631631 if (isParsingInvalidChunkedEncoding (remainingStreamingBytes)) {
632- if (errorHandler) {
633- errorHandler (&req, HTTP_ERROR_400_BAD_REQUEST);
634- }
632+ errorHandler (&req, HTTP_ERROR_400_BAD_REQUEST);
635633 return {HTTP_ERROR_400_BAD_REQUEST, FULLPTR};
636634 }
637635 data = (char *) dataToConsume.data ();
@@ -669,9 +667,7 @@ struct HttpParser {
669667 // break here on break
670668 std::pair<unsigned int , void *> consumed = fenceAndConsumePostPadded<true >(fallback.data (), (unsigned int ) fallback.length (), user, reserved, &req, requestHandler, dataHandler);
671669 if (consumed.second != user) {
672- if (errorHandler) {
673- errorHandler (&req, consumed.first );
674- }
670+ errorHandler (&req, consumed.first );
675671 return consumed;
676672 }
677673
@@ -692,9 +688,7 @@ struct HttpParser {
692688 dataHandler (user, chunk, chunk.length () == 0 );
693689 }
694690 if (isParsingInvalidChunkedEncoding (remainingStreamingBytes)) {
695- if (errorHandler) {
696- errorHandler (&req, HTTP_ERROR_400_BAD_REQUEST);
697- }
691+ errorHandler (&req, HTTP_ERROR_400_BAD_REQUEST);
698692 return {HTTP_ERROR_400_BAD_REQUEST, FULLPTR};
699693 }
700694 data = (char *) dataToConsume.data ();
@@ -722,9 +716,7 @@ struct HttpParser {
722716
723717 } else {
724718 if (fallback.length () == MAX_FALLBACK_SIZE) {
725- if (errorHandler) {
726- errorHandler (&req, HTTP_ERROR_431_REQUEST_HEADER_FIELDS_TOO_LARGE);
727- }
719+ errorHandler (&req, HTTP_ERROR_431_REQUEST_HEADER_FIELDS_TOO_LARGE);
728720 return {HTTP_ERROR_431_REQUEST_HEADER_FIELDS_TOO_LARGE, FULLPTR};
729721 }
730722 return {0 , user};
@@ -733,9 +725,7 @@ struct HttpParser {
733725
734726 std::pair<unsigned int , void *> consumed = fenceAndConsumePostPadded<false >(data, length, user, reserved, &req, requestHandler, dataHandler);
735727 if (consumed.second != user) {
736- if (errorHandler) {
737- errorHandler (&req, consumed.first );
738- }
728+ errorHandler (&req, consumed.first );
739729 return consumed;
740730 }
741731
@@ -746,9 +736,7 @@ struct HttpParser {
746736 if (length < MAX_FALLBACK_SIZE) {
747737 fallback.append (data, length);
748738 } else {
749- if (errorHandler) {
750- errorHandler (&req, HTTP_ERROR_431_REQUEST_HEADER_FIELDS_TOO_LARGE);
751- }
739+ errorHandler (&req, HTTP_ERROR_431_REQUEST_HEADER_FIELDS_TOO_LARGE);
752740 return {HTTP_ERROR_431_REQUEST_HEADER_FIELDS_TOO_LARGE, FULLPTR};
753741 }
754742 }
0 commit comments