Ejemplo n.º 1
0
void ESP8266WebServer::send(int code, const char* content_type, const String& content) {
    String header;
    _prepareHeader(header, code, content_type, content.length());
    sendContent(header);

    sendContent(content);
}
Ejemplo n.º 2
0
void ESP8266WebServer::send_P(int code, PGM_P content_type, PGM_P content, size_t contentLength) {
    String header;
    char type[64];
    memccpy_P((void*)type, (PGM_VOID_P)content_type, 0, sizeof(type));
    _prepareHeader(header, code, (const char* )type, contentLength);
    sendContent(header);
    sendContent_P(content, contentLength);
}
Ejemplo n.º 3
0
void WebServer::sendPage (WebClient* client) {
	unsigned int l = strlen (client -> request.url);
	if (l == 0 || client -> request.url[l - 1] == '/') {
		// Request for "/", redirect
		DPRINT (F("Redirecting to "));
		DPRINT (client -> request.url);
		DPRINTLN (F(REDIRECT_ROOT_PAGE));

		client -> print (F(HEADER_START REDIRECT_HEADER));
		if (l == 0)
			client -> print ('/');
		else
			client -> print (client -> request.url);
		client -> print (F(REDIRECT_ROOT_PAGE HEADER_END));
	} else {
		const Page *page;
		char *pagename = client -> request.get_basename ();

#if defined (WEBBINO_ENABLE_SD) || defined (WEBBINO_ENABLE_SDFAT)
		if (SD.exists (pagename)) {
			DPRINT (F("Sending page from SD file "));
			DPRINTLN (pagename);

			SDContent content = SDContent (pagename);
			sendContent (client, &content);
		} else
#endif
		if ((page = getPage (pagename))) {
			// Call page function
			PageFunction func = page -> getFunction ();
			if (func)
				func (client -> request);

			FlashContent content = FlashContent (page);
			sendContent (client, &content);
		} else {
			client -> print (F(HEADER_START NOT_FOUND_HEADER HEADER_END));

			client -> print (F("<html><body><h3>No such page: \""));
			client -> print (pagename);
			client -> print (F("\"</h3></body></html>"));
		}
	}

	client -> sendReply ();
}
Ejemplo n.º 4
0
void MailSender::sendMail()
{
    if (!_mail)
        return;

    sendHeader();
    sendContent();
    sendEnd();
}
Ejemplo n.º 5
0
void ESP8266WebServer::send(int code, const char* content_type, const String& content) {
    String header;
    // Can we asume the following?
    //if(code == 200 && content.length() == 0 && _contentLength == CONTENT_LENGTH_NOT_SET)
    //  _contentLength = CONTENT_LENGTH_UNKNOWN;
    _prepareHeader(header, code, content_type, content.length());
    _currentClient.write(header.c_str(), header.length());
    if(content.length())
      sendContent(content);
}
Ejemplo n.º 6
0
bool MailSender::sendMail()
{
    if (!_mail)
        return false;

    if (!sendHeader())
    	return false;
    if (!sendContent())
    	return false;
    if (!sendEnd())
    	return false;
    return true;
}
Ejemplo n.º 7
0
void RssObject::getContent(QString content)
{
       emit sendContent(content);
}
Ejemplo n.º 8
0
void ESP8266WebServer::_finalizeResponse() {
  if (_chunked) {
    sendContent("");
  }
}