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

Connection: close and Connection: keep-alive both present in the header #8205

Closed
2 tasks
enjoyneering opened this issue Jul 9, 2021 · 1 comment
Closed
2 tasks

Comments

@enjoyneering
Copy link

enjoyneering commented Jul 9, 2021

Basic Infos

  • [x ] This issue complies with the issue POLICY doc.
  • [x ] I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • [x ] I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • [x ] I have filled out all fields below.

Platform

  • Hardware: [ESP-12]
  • Core Version: [3.0.1]
  • Development Env: [Arduino IDE]
  • Operating System: [Windows]

Settings in IDE

  • Module: [Wemos D1 mini r2]
  • Flash Mode: [qio]
  • Flash Size: [4MB]
  • lwip Variant: [v2 Higher Bandwidth]
  • Reset Method: [nodemcu]
  • Flash Frequency: [80Mhz]
  • CPU Frequency: [80Mhz]
  • Upload Using: [OTA]
  • Upload Speed: [115200] (serial upload only)

Problem Description

Accordind to the comment in ESP8266WebServer.h - if the client sends the "Connection" header, the value given by the header is used. But in fact, both server.keepAlive(true); and server.sendHeader(F("Connection"), F("close")); server.send(200); is present in the header.

HTTP/1.1 200 OK
Content-Type:
Connection: close
Content-Length: 0
Connection: keep-alive
Keep-Alive: timeout=2000

UDP:
For some reason short version server.send(200, F("Connection"), F("close")); doesn't work (only keep-alive is present).

@d-a-v d-a-v added this to the 3.1 milestone Jul 9, 2021
@mcspr
Copy link
Collaborator

mcspr commented Jul 1, 2022

Accordind to the comment in ESP8266WebServer.h - if the client sends the "Connection" header, the value given by the header is used. But in fact, both server.keepAlive(true); and server.sendHeader(F("Connection"), F("close")); server.send(200); is present in the header.

Works as intended per #7414?

Connection: {Keep-Alive,close} is not meant to be sent by the user, but by the server internals through setting keep alive flag. But, I suppose we may add some code to reject such internal header(s). Internally, keep-alive is first sourced from the HTTP version, then checks whether the request contains Connection: and again updates the flag when it equals to keep-alive and otherwise defaults to close

Plus, I don't see how multiple 'Connection's may sneak into the response headers string; server code only sends it once. But, we don't check for unique / duplicates / internal header fields, so it is possible for user to inject something unexpected (and the spec technically allows it)

For some reason short version server.send(200, F("Connection"), F("close")); doesn't work (only keep-alive is present).

Invalid? Call will respond with 'content-type: connection' and 'close' in the body

void send(int code, const String& content_type, const String& content);

@mcspr mcspr closed this as completed Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants