Ejemplo n.º 1
0
Node *Parser::parse(uHTTP::URL *url) {
  LogInfo("parse,TID(0x%04x): %s\n", GetCurrentThreadId(), url->getSting()); 
  HTTPRequest httpReq;
  HTTPResponse *httpRes = NULL;
  {
      FUNCTION_BLOCK_NAME_TRACE("post", 100);

      const char *host = url->getHost();
      int port = url->getPort();
      std::string target = url->getTarget();

      httpReq.setMethod(HTTP::GET);
      httpReq.setURI(target);
      httpRes = httpReq.post(host, port);
      if (httpRes->isSuccessful() == false){
          return NULL;
      }
  }

  Node* pNode = NULL;
  {
      FUNCTION_BLOCK_NAME_TRACE("ParseContent", 100);
     const char *contents = httpRes->getContent();
     pNode = parse(contents);
  }
  
  return pNode;
}
Ejemplo n.º 2
0
Node *Parser::parse(uHTTP::URL *url)
{
  const char *host = url->getHost();
  int port = url->getPort();
  const char *uri = url->getPath();
  HTTPRequest httpReq;
  httpReq.setMethod(HTTP::GET);
  httpReq.setURI(uri);
  HTTPResponse *httpRes = httpReq.post(host, port);
  if (httpRes->isSuccessful() == false)
    return NULL;
  const char *contents = httpRes->getContent();
  return parse(contents);
}