Beispiel #1
0
  inline void download(const string &path, uint8_t *&data, unsigned &size) {
    data = 0;
    size = 0;

    send({
      "GET ", path, " HTTP/1.1\r\n"
      "Host: ", hostname, "\r\n"
      "Connection: close\r\n"
      "\r\n"
    });

    header = downloadHeader();
    downloadContent(data, size);
  }
Beispiel #2
0
  inline bool download(const string &path) {
    total_length = 0;
    total_read = 0;

    send({
      "GET ", path, " HTTP/1.1\r\n"
      "Host: ", hostname, "\r\n"
      "Connection: close\r\n"
      "User-Agent: nall::http\r\n"
      "\r\n"
    });

    header = downloadHeader();
    if(!header.iposition("200 OK"))
      return false;

    return downloadContent();
  }
bool	HttpClient::getResponse()
{
	std::string	body_header;		//收取的Body和Header的混合体
	if (downloadHeader(body_header))
	{
		//如果请求指定只需要获取Http头直接返回 (主要是为分段下载减少下载量)
		if (_request->onlyDownloadHeader())
		{
			return true;
		}
		else
		{
			return	downloadBody(body_header);
		}
	}
	else
	{
		return	false;
	}
}