Beispiel #1
0
bool litehtml::el_table::appendChild(const litehtml::element::ptr& el)
{
	if(!el)	return false;
	if(!t_strcmp(el->get_tagName(), _t("tbody")) || !t_strcmp(el->get_tagName(), _t("thead")) || !t_strcmp(el->get_tagName(), _t("tfoot")))
	{
		return html_tag::appendChild(el);
	}
	return false;
}
Beispiel #2
0
void litehtml::el_link::parse_attributes()
{
	bool processed = false;

	const tchar_t* rel = get_attr(_t("rel"));
	if(rel && !t_strcmp(rel, _t("stylesheet")))
	{
		const tchar_t* media	= get_attr(_t("media"));
		const tchar_t* href		= get_attr(_t("href"));
		if(href && href[0])
		{
			tstring css_text;
			tstring css_baseurl;
			m_doc->container()->import_css(css_text, href, css_baseurl);
			if(!css_text.empty())
			{
				m_doc->add_stylesheet(css_text.c_str(), css_baseurl.c_str(), media);
				processed = true;
			}
		}
	}

	if(!processed)
	{
		m_doc->container()->link(m_doc, this);
	}
}
void MTD_FLASHMEM HTTPHandler::dispatch() {
  for (uint32_t i = 0; i != m_routesCount; ++i) {
    if (f_strcmp(FSTR("*"), m_routes[i].page) == 0 ||
        t_strcmp(m_request.requestedPage, CharIterator(m_routes[i].page)) == 0) {
      (this->*m_routes[i].pageHandler)();
      return;
    }
  }
  // not found (routes should always have route "*" to handle 404 not found)
}
    void MTD_FLASHMEM DefaultHTTPHandler::dispatch()
    {
#if (FDV_INCLUDE_SERIALBINARY == 1)            
        if (ConfigurationManager::getSerialBinary() && ConfigurationManager::getSerialBinary()->isReady())
        {
            StringList* routes = ConfigurationManager::getSerialBinary()->getHTTPRoutes();
            if (routes)
            {                
                for (uint32_t i = 0; i != routes->size(); ++i)
                {
                    if (f_strcmp(FSTR("*"), routes->getItem(i)) == 0 || t_strcmp(getRequest().requestedPage, CharIterator(routes->getItem(i))) == 0)
                    {
                        ConfigurationManager::getSerialBinary()->send_CMD_HTTPREQUEST(i, this);
                        return;
                    }
                }
            }
        }
#endif            
        HTTPHandler::dispatch();
    }
bool MTD_FLASHMEM HTTPHandler::processRequest() {
  // look for 0x0D 0x0A 0x0D 0x0A
  CharChunksIterator headerEnd =
      t_strstr(m_receivedData.getIterator(), CharChunksIterator(), CharIterator(FSTR("\x0D\x0A\x0D\x0A")));
  if (headerEnd.isValid()) {
    // move header end after CRLFCRLF
    headerEnd += 4;

    CharChunksIterator curc = m_receivedData.getIterator();

    // extract method (GET, POST, etc..)
    CharChunksIterator method = curc;
    while (curc != headerEnd && *curc != ' ')
      ++curc;
    *curc++ = 0; // ends method
    if (t_strcmp(method, CharIterator(FSTR("GET"))) == 0)
      m_request.method = Get;
    else if (t_strcmp(method, CharIterator(FSTR("POST"))) == 0)
      m_request.method = Post;
    else if (t_strcmp(method, CharIterator(FSTR("HEAD"))) == 0)
      m_request.method = Head;
    else
      m_request.method = Unsupported;

    // extract requested page and query parameters
    m_request.requestedPage = curc;
    while (curc != headerEnd) {
      if (*curc == '?') {
        *curc++ = 0; // ends requestedPage
        curc = extractURLEncodedFields(curc, headerEnd, &m_request.query);
        break;
      } else if (*curc == ' ') {
        *curc++ = 0; // ends requestedPage
        break;
      }
      ++curc;
    }

    // bypass HTTP version
    while (curc != headerEnd && *curc != 0x0D)
      ++curc;

    // extract headers
    curc = extractHeaders(curc, headerEnd, &m_request.headers);

    // get content length (may be NULL)
    char const *contentLengthStr = m_request.headers[STR_Content_Length];
    int32_t contentLength = contentLengthStr ? strtol(contentLengthStr, NULL, 10) : 0;

    if (m_request.method == Post) {
      // check content type (POST)
      char const *contentType = m_request.headers[STR_Content_Type];
      if (contentType && f_strstr(contentType, FSTR("multipart/form-data"))) {
        //// content type is multipart/form-data
        processMultipartFormData(headerEnd, contentLength, contentType);
      } else if (contentType == NULL ||
                 (contentType && f_strstr(contentType, FSTR("application/x-www-form-urlencoded")))) {
        //// content type is application/x-www-form-urlencoded
        processXWWWFormUrlEncoded(headerEnd, contentLength);
      }
    } else
      dispatch();

    return true;
  } else {
    // header is not complete
    return false;
  }
}