@@ -74,7 +74,7 @@ struct HttpContext {
74
74
if (!us_socket_is_closed (SSL, s) && !us_socket_is_shut_down (SSL, s)) {
75
75
HttpContextData<SSL> *httpContextData = getSocketContextDataS (s);
76
76
77
- if (httpContextData->rejectUnauthorized ) {
77
+ if (httpContextData->flags . rejectUnauthorized ) {
78
78
if (!success || verify_error.error != 0 ) {
79
79
// we failed to handshake, close the socket
80
80
us_socket_close (SSL, s, 0 , nullptr );
@@ -163,7 +163,7 @@ struct HttpContext {
163
163
((AsyncSocket<SSL> *) s)->cork ();
164
164
165
165
/* Mark that we are inside the parser now */
166
- httpContextData->isParsingHttp = true ;
166
+ httpContextData->flags . isParsingHttp = true ;
167
167
168
168
// clients need to know the cursor after http parse, not servers!
169
169
// how far did we read then? we need to know to continue with websocket parsing data? or?
@@ -174,7 +174,7 @@ struct HttpContext {
174
174
#endif
175
175
176
176
/* The return value is entirely up to us to interpret. The HttpParser cares only for whether the returned value is DIFFERENT from passed user */
177
- auto [err, returnedSocket] = httpResponseData->consumePostPadded (httpContextData->requireHostHeader ,data, (unsigned int ) length, s, proxyParser, [httpContextData](void *s, HttpRequest *httpRequest) -> void * {
177
+ auto [err, parserError, returnedSocket] = httpResponseData->consumePostPadded (httpContextData->flags . requireHostHeader ,data, (unsigned int ) length, s, proxyParser, [httpContextData](void *s, HttpRequest *httpRequest) -> void * {
178
178
/* For every request we reset the timeout and hang until user makes action */
179
179
/* Warning: if we are in shutdown state, resetting the timer is a security issue! */
180
180
us_socket_timeout (SSL, (us_socket_t *) s, 0 );
@@ -290,10 +290,14 @@ struct HttpContext {
290
290
});
291
291
292
292
/* Mark that we are no longer parsing Http */
293
- httpContextData->isParsingHttp = false ;
293
+ httpContextData->flags . isParsingHttp = false ;
294
294
295
295
/* If we got fullptr that means the parser wants us to close the socket from error (same as calling the errorHandler) */
296
296
if (returnedSocket == FULLPTR) {
297
+ auto onClientError = httpContextData->onClientError ;
298
+ if (onClientError) {
299
+ onClientError (httpResponseData->socketData , SSL, s, parserError, data, length);
300
+ }
297
301
/* For errors, we only deliver them "at most once". We don't care if they get halfways delivered or not. */
298
302
us_socket_write (SSL, s, httpErrorResponses[err].data (), (int ) httpErrorResponses[err].length (), false );
299
303
us_socket_shutdown (SSL, s);
@@ -467,7 +471,7 @@ struct HttpContext {
467
471
/* Init socket context data */
468
472
auto * httpContextData = new ((HttpContextData<SSL> *) us_socket_context_ext (SSL, (us_socket_context_t *) httpContext)) HttpContextData<SSL>();
469
473
if (options.request_cert && options.reject_unauthorized ) {
470
- httpContextData->rejectUnauthorized = true ;
474
+ httpContextData->flags . rejectUnauthorized = true ;
471
475
}
472
476
return httpContext->init ();
473
477
}
@@ -515,7 +519,7 @@ struct HttpContext {
515
519
}
516
520
}
517
521
518
- const bool &customContinue = httpContextData->usingCustomExpectHandler ;
522
+ const bool &customContinue = httpContextData->flags . usingCustomExpectHandler ;
519
523
520
524
httpContextData->currentRouter ->add (methods, pattern, [handler = std::move (handler), parameterOffsets = std::move (parameterOffsets), &customContinue](auto *r) mutable {
521
525
auto user = r->getUserData ();
0 commit comments