-
Notifications
You must be signed in to change notification settings - Fork 13.3k
add ESP8266WebServer::sendContent_P and ESP8266WebServer::send_P with contentLength #753
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
Conversation
martinayotte
commented
Sep 6, 2015
- add ESP8266WebServer::sendContent_P and ESP8266WebServer::send_P with size_t contentLength argument to allow binary content to be send, such as images.
- fix in WiFiClient::write_P to use memcpy instead of memccpy allow binary content to be send, such as images.
…uced few minutes ago when changing memccpy_P to memcpy_P
…uced few minutes ago when changing memccpy_P to memcpy_P
@@ -169,6 +169,13 @@ void ESP8266WebServer::send_P(int code, PGM_P content_type, PGM_P content) { | |||
sendContent_P(content); | |||
} | |||
|
|||
void ESP8266WebServer::send_P(int code, PGM_P content_type, PGM_P content, size_t contentLength) { | |||
String header; | |||
_prepareHeader(header, code, String(FPSTR(content_type)).c_str(), contentLength); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch, you are calling c_str()
method of a temporary String instance here. Better move String declaration into a separate line.
Hi IGRR, |
Oh okay, somehow i missed that. I'll merge everything then and do the necessary changes. |
Hi again Ivan, I hate putting my hands/arms into a wringer, especially when it is not my own code. During my previous tests, I forgot to add PSTR("image/png") in my calls. prepareHeader(header, code, String(FPSTR(content_type)).c_str(), contentLength); Changing that to what you suggest me doesn't work either : String type = String(FPSTR(content_type)); So, I've think the proper way is again to use memccpy_P(), but I feel it is a bit ugly : char type[64]; I will commit that for now, but I think it needs to be revisited... |
…Server::send_P() functions
add ESP8266WebServer::sendContent_P and ESP8266WebServer::send_P with contentLength
add ESP8266WebServer::sendContent_P and ESP8266WebServer::send_P with contentLength