http_socket.close(); // You will need to connect to the "http" service on // the computer whose name is in the "host" string, // then request the URL path given in the "path" string.
// Then you'll need to print out everything the server sends back, // (not just one call to read() -- everything) until you reach // the "eof" (end of file). }
for(size_t i = 0; i < write_sz; i++){ dq_.push_back(data[i]); }
return write_sz; }
//! \param[in] len bytes will be copied from the output side of the buffer stringByteStream::peek_output(constsize_t len)const { // dq_中的内容不会被清除 size_t pop_size = min(len, dq_.size()); returnstring(dq_.begin(), dq_.begin() + pop_size); }
//! \param[in] len bytes will be removed from the output side of the buffer voidByteStream::pop_output(constsize_t len) { //dq_中的内容会被清除 size_t pop_size = min(len, dq_.size()); read_size_ += pop_size; for(size_t i = 0; i < pop_size; i++){ dq_.pop_front(); } }
//! Read (i.e., copy and then pop) the next "len" bytes of the stream //! \param[in] len bytes will be popped and returned //! \returns a string std::stringByteStream::read(constsize_t len) { std::string ret = peek_output(len); pop_output(len); return ret; }