Changed some parameters from std::iostream to std::istream in Client and Server
This commit is contained in:
parent
361ac21518
commit
8ec36d19fd
2 changed files with 11 additions and 11 deletions
|
|
@ -145,7 +145,7 @@ namespace SimpleWeb {
|
|||
|
||||
/// Convenience function to perform synchronous request. The io_service is run within this function.
|
||||
/// If reusing the io_service for other tasks, please use the asynchronous request functions instead.
|
||||
std::shared_ptr<Response> request(const std::string& method, const std::string& path, std::iostream& content, const CaseInsensitiveMultimap& header=CaseInsensitiveMultimap()) {
|
||||
std::shared_ptr<Response> request(const std::string& method, const std::string& path, std::istream& content, const CaseInsensitiveMultimap& header=CaseInsensitiveMultimap()) {
|
||||
std::shared_ptr<Response> response;
|
||||
request(method, path, content, header, [&response](std::shared_ptr<Response> response_, const error_code &ec) {
|
||||
response=response_;
|
||||
|
|
@ -201,7 +201,7 @@ namespace SimpleWeb {
|
|||
}
|
||||
|
||||
/// Asynchronous request where setting and/or running Client's io_service is required.
|
||||
void request(const std::string &method, const std::string &path, std::iostream& content, const CaseInsensitiveMultimap& header,
|
||||
void request(const std::string &method, const std::string &path, std::istream& content, const CaseInsensitiveMultimap& header,
|
||||
std::function<void(std::shared_ptr<Response>, const error_code&)> &&request_callback_) {
|
||||
auto session=std::make_shared<Session>(io_service, get_connection(), create_request_header(method, path, header));
|
||||
auto request_callback=std::make_shared<std::function<void(std::shared_ptr<Response>, const error_code&)>>(std::move(request_callback_));
|
||||
|
|
@ -216,9 +216,9 @@ namespace SimpleWeb {
|
|||
(*request_callback)(session->response, ec);
|
||||
};
|
||||
|
||||
content.seekp(0, std::ios::end);
|
||||
auto content_length=content.tellp();
|
||||
content.seekp(0, std::ios::beg);
|
||||
content.seekg(0, std::ios::end);
|
||||
auto content_length=content.tellg();
|
||||
content.seekg(0, std::ios::beg);
|
||||
std::ostream write_stream(session->request_buffer.get());
|
||||
if(content_length>0)
|
||||
write_stream << "Content-Length: " << content_length << "\r\n";
|
||||
|
|
@ -230,7 +230,7 @@ namespace SimpleWeb {
|
|||
}
|
||||
|
||||
/// Asynchronous request where setting and/or running Client's io_service is required.
|
||||
void request(const std::string &method, const std::string &path, std::iostream& content,
|
||||
void request(const std::string &method, const std::string &path, std::istream& content,
|
||||
std::function<void(std::shared_ptr<Response>, const error_code&)> &&request_callback) {
|
||||
request(method, path, content, CaseInsensitiveMultimap(), std::move(request_callback));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,11 +94,11 @@ namespace SimpleWeb {
|
|||
}
|
||||
|
||||
/// Convenience function for writing status line, header fields, and content
|
||||
void write(StatusCode status_code, std::iostream &content, const CaseInsensitiveMultimap &header=CaseInsensitiveMultimap()) {
|
||||
void write(StatusCode status_code, std::istream &content, const CaseInsensitiveMultimap &header=CaseInsensitiveMultimap()) {
|
||||
*this << "HTTP/1.1 " << SimpleWeb::status_code(status_code) << "\r\n";
|
||||
content.seekp(0, std::ios::end);
|
||||
auto size=content.tellp();
|
||||
content.seekp(0, std::ios::beg);
|
||||
content.seekg(0, std::ios::end);
|
||||
auto size=content.tellg();
|
||||
content.seekg(0, std::ios::beg);
|
||||
write_header(header, size);
|
||||
if(size)
|
||||
*this << content.rdbuf();
|
||||
|
|
@ -110,7 +110,7 @@ namespace SimpleWeb {
|
|||
}
|
||||
|
||||
/// Convenience function for writing success status line, header fields, and content
|
||||
void write(std::iostream &content, const CaseInsensitiveMultimap &header=CaseInsensitiveMultimap()) {
|
||||
void write(std::istream &content, const CaseInsensitiveMultimap &header=CaseInsensitiveMultimap()) {
|
||||
write(StatusCode::success_ok, content, header);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue