/// checks the validity of the HTTP response void checkResponse(const HTTPResponse& http_response) { BOOST_REQUIRE(http_response.getStatusCode() == 200); BOOST_CHECK(! http_response.hasHeader(HTTPTypes::HEADER_CONTENT_LENGTH)); BOOST_REQUIRE(http_response.getContentLength() == BIG_BUF_SIZE); BOOST_CHECK_EQUAL(memcmp(http_response.getContent(), m_big_buf, BIG_BUF_SIZE), 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; }
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); }