Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
renamed callack to log
  • Loading branch information
pdeltour-syna committed Oct 7, 2025
commit e598b0168f9a6a75b8b648a4875f2ce1f139d908
2 changes: 1 addition & 1 deletion docs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ export interface TemplatedApp {
filter(cb: (res: HttpResponse, count: Number) => void | Promise<void>) : TemplatedApp;
/** Registers an HTTP parsing error handler that is called when malformed HTTP requests are encountered.
* The handler receives the request object (or null if request is too malformed), HTTP status code, and complete response body. */
onHttpParsingError(cb: (req: HttpRequest | null, statusCode: number, responseBody: ArrayBuffer) => void | Promise<void>) : TemplatedApp;
log(cb: (req: HttpRequest | null, statusCode: number, responseBody: ArrayBuffer) => void | Promise<void>) : TemplatedApp;
/** Closes all sockets including listen sockets. This will forcefully terminate all connections. */
close() : TemplatedApp;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/HttpParsingErrorHandling.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const uWS = require('../src/uws.js');

const app = uWS.App({
// Optional SSL configuration
}).onHttpParsingError((req, httpStatus, responseBody) => {
}).log((req, httpStatus, responseBody) => {
console.log('HTTP parsing error occurred with status:', httpStatus);

if (req) {
Expand Down
6 changes: 3 additions & 3 deletions src/AppWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ void uWS_App_filter(const FunctionCallbackInfo<Value> &args) {
}

template <typename APP>
void uWS_App_onHttpParsingError(const FunctionCallbackInfo<Value> &args) {
void uWS_App_log(const FunctionCallbackInfo<Value> &args) {
APP *app = (APP *) args.This()->GetAlignedPointerFromInternalField(0);

/* Handler */
Expand All @@ -584,7 +584,7 @@ void uWS_App_onHttpParsingError(const FunctionCallbackInfo<Value> &args) {
/* This function requires perContextData */
PerContextData *perContextData = (PerContextData *) Local<External>::Cast(args.Data())->Value();

app->onHttpParsingError([cb = std::move(cb), perContextData](auto *req, int statusCode, std::string_view responseBody) {
app->log([cb = std::move(cb), perContextData](auto *req, int statusCode, std::string_view responseBody) {
Isolate *isolate = perContextData->isolate;
HandleScope hs(isolate);

Expand Down Expand Up @@ -1035,7 +1035,7 @@ void uWS_App(const FunctionCallbackInfo<Value> &args) {
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "close", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_close<APP>, args.Data()));
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "listen_unix", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_listen_unix<APP>, args.Data()));
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "filter", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_filter<APP>, args.Data()));
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "onHttpParsingError", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_onHttpParsingError<APP>, args.Data()));
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "log", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_log<APP>, args.Data()));

/* load balancing */
appTemplate->PrototypeTemplate()->Set(String::NewFromUtf8(isolate, "removeChildAppDescriptor", NewStringType::kNormal).ToLocalChecked(), FunctionTemplate::New(isolate, uWS_App_removeChildApp<APP>, args.Data()));
Expand Down