示例#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);
}
示例#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);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// send web content with handler function to process the data
//////////////////////////////////////////////////////////////////////////////////////////////////
void ESP8266WebServerEx::sendEx(int code, const char* content_type, const char* data, size_t contentLength, TDataProcessingHandler handler) {
  String header;
  char buf[34];

  //if ( !VerifyCookie(content_type) ) return;
  sendDateHeader(buf);
  _prepareHeader(header, code, content_type, contentLength);
  _currentClient.write(header.c_str(), header.length());
  sendWebData(data,contentLength,handler);
}
示例#4
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);
}
示例#5
0
void ESP8266WebServer::send_P(int code, PGM_P content_type, PGM_P content) {
    size_t contentLength = 0;

    if (content != NULL) {
        contentLength = strlen_P(content);
    }

    String header;
    char type[64];
    memccpy_P((void*)type, (PGM_VOID_P)content_type, 0, sizeof(type));
    _prepareHeader(header, code, (const char* )type, contentLength);
    _currentClient.write(header.c_str(), header.length());
    sendContent_P(content);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
// send data to client. Data is read from ROM  
// expire is # of seconds the cache will be expired.
//////////////////////////////////////////////////////////////////////////////////////////////////
void ESP8266WebServerEx::sendEx(int code, const char* content_type, const char* data, size_t contentLength, bool bGzip, unsigned long expire) {

  if ( !VerifyCookie(content_type) ) return;
  
  String header;
  char buf[34];
    
  if ( bGzip ) sendHeader("Content-Encoding", "gzip");

  sendDateHeader(buf);
  if ( expire ) {
    sprintf(buf,"max-age=%lu",expire);
    sendHeader("Cache-Control",buf);
    sprintf(buf,"%lu",(unsigned long)contentLength);
    sendHeader("ETag",buf);
  }
  _prepareHeader(header, code, content_type, contentLength);
  _currentClient.write(header.c_str(), header.length());
  sendWebData(data,contentLength);
}
示例#7
0
Terminal::Terminal(Core core, QWidget * parent) :
	TabTerminal(parent),
	AbstractComponent(core)
{
	connect(this, SIGNAL(command(QString)), this, SLOT(_prepareHeader(QString)));
}