Skip to content

SDWebServer.ino example produces duplicate HTTP headers #395

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

Closed
sunnyhighway opened this issue Jun 6, 2015 · 1 comment
Closed

SDWebServer.ino example produces duplicate HTTP headers #395

sunnyhighway opened this issue Jun 6, 2015 · 1 comment

Comments

@sunnyhighway
Copy link

The SDWebServer.ino example produces duplicate HTTP headers.

Current code:

void returnOK() {
  server.sendHeader("Connection", "close");
  server.sendHeader("Access-Control-Allow-Origin", "*");
  server.send(200, "text/plain", "");
}

void returnFail(String msg) {
  server.sendHeader("Connection", "close");
  server.sendHeader("Access-Control-Allow-Origin", "*");
  server.send(500, "text/plain", msg + "\r\n");
}

server.send() already injects the "Connection" and "Access-Control-Allow-Origin" headers.
No point in doing that twice. (browsers could get confused)

Proposal:

void returnOK() {
  server.send(200, "text/plain", "");
}

void returnFail(String msg) {
  server.send(500, "text/plain", msg + "\r\n");
}
Links2004 added a commit to Links2004/Arduino that referenced this issue Nov 27, 2015
server.send() already injects the "Connection" and "Access-Control-Allow-Origin" headers.
No point in doing that twice. (browsers could get confused)
@Links2004
Copy link
Collaborator

will be merged soon

Links2004 added a commit that referenced this issue Nov 27, 2015
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

2 participants