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

Request disable sending Content-Length: 0 on HEAD #1393

Open
DRSDavidSoft opened this issue Apr 6, 2024 · 1 comment
Open

Request disable sending Content-Length: 0 on HEAD #1393

DRSDavidSoft opened this issue Apr 6, 2024 · 1 comment

Comments

@DRSDavidSoft
Copy link

I would prefer to do something like this:

if (request->method() == HTTP_HEAD)
{
	response = request->beginResponse(200, "application/octet-stream", "");
	response->setContentLength(0);
	response->setSendContentLength(false); // ?????
	response->addHeader("Content-Length", String(FinalDataSize));
}

Instead, I have to do this:

if (request->method() == HTTP_HEAD)
{
	response = request->beginResponse(200, "application/octet-stream", "");
	response->setContentLength(0);
	response->addHeader("Content-Length", String(FinalDataSize));
}

Which is bad, because it sends the Content-Length twice, once with the incorrect value of 0 and once with the correct Data size. Notice, in the HEAD request we must specify the data's correct Content-Length but MUST NOT send any content whatsover.

If I do response->setContentLength(15); for example, then ESPAsyncWebServer will send 15 bytes of unknown memory to the client which is obviously invalid.

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

No branches or pull requests

1 participant