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

Can't get rid of Server header: "uWebSockets_20" #177

Open
wedobetter opened this issue May 25, 2024 · 5 comments
Open

Can't get rid of Server header: "uWebSockets_20" #177

wedobetter opened this issue May 25, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@wedobetter
Copy link

wedobetter commented May 25, 2024

I have tried to overwrite it:

async def healthcheck(res: Response, _: Request, __=None):
    res.write_status(200)
    return res.end_without_body(True)

def headers_mw(res: Response, _: Request, __=None):
    return res.write_header("Server", "myserver")

basic_router = MiddlewareRouter(app, headers_mw)
basic_router.head("/health", healthcheck)

and I ended up with this:

curl -i -I http://127.0.0.1:9999/health

HTTP/1.1 200 OK
Server:  myserver
Connection: close
Date: Sat, 25 May 2024 19:52:29 GMT
Server: uWebSockets_20
@RajaSunrise
Copy link

If you use "Res.Write_Header ()" you are like overwriting the header, so it becomes 2 headers, the other header is run using uwebsocket in the source native.py file that connects uwebsocket

@cirospaciari
Copy link
Owner

This is a issue with uWS we will move to using a customized version, so we can set the Server header as a server option.

@stancikcom
Copy link

@cirospaciari why not to simply modify this macro?

#ifndef UWS_HTTPRESPONSE_NO_WRITEMARK
        if (!Super::getLoopData()->noMark) {
            /* We only expose major version */
            writeHeader("uWebSockets", "20");
        }
#endif

in this file in https://github.com/uNetworking/uWebSockets/blob/master/src/HttpResponse.h

@RajaSunrise
Copy link

wow, that's amazing bro, you must check the uwebsockets code one by one

@cirospaciari cirospaciari added the enhancement New feature or request label Jul 13, 2024
@cirospaciari
Copy link
Owner

cirospaciari commented Jul 19, 2024

This is pretty easy to fix, before sending the body (write/send/end) we need to check if we already sent the Server header, if not will use the default, will add a option to hide this server header if someone just dont wanna to see "uWebSockets" ou "socketify" on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants