aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/hicn/transport/http/message.h
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2020-02-18 16:21:07 +0100
committerMauro Sardara <msardara@cisco.com>2020-02-18 17:06:12 +0100
commit46c924b9d2edd84bc6ecb5367ba52fcff82804fa (patch)
tree0e1aa2f6c14480bb0b06109cf6c1385a20cdadb5 /libtransport/src/hicn/transport/http/message.h
parent4590ae6202d7f3fbf932a57e4d9500ce5ac1e473 (diff)
[HICN-528] Add progress bar to higet.
Change-Id: I645ef2b8834f4310933793fb1f59e8f37e3d6aef Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'libtransport/src/hicn/transport/http/message.h')
-rw-r--r--libtransport/src/hicn/transport/http/message.h20
1 files changed, 15 insertions, 5 deletions
diff --git a/libtransport/src/hicn/transport/http/message.h b/libtransport/src/hicn/transport/http/message.h
index 270dd3f0e..b8756224f 100644
--- a/libtransport/src/hicn/transport/http/message.h
+++ b/libtransport/src/hicn/transport/http/message.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2020 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -19,6 +19,8 @@
#include <hicn/transport/portability/win_portability.h>
#endif
+#include <hicn/transport/utils/membuf.h>
+
#include <map>
#include <sstream>
#include <vector>
@@ -37,17 +39,25 @@ static std::map<HTTPMethod, std::string> method_map = {
};
typedef std::map<std::string, std::string> HTTPHeaders;
-typedef std::vector<uint8_t> HTTPPayload;
+typedef std::unique_ptr<utils::MemBuf> HTTPPayload;
class HTTPMessage {
public:
virtual ~HTTPMessage() = default;
- virtual const HTTPHeaders &getHeaders() = 0;
+ const HTTPHeaders getHeaders() { return headers_; };
+
+ void coalescePayloadBuffer() {
+ auto it = headers_.find("Content-Length");
+ if (it != headers_.end()) {
+ auto content_length = std::stoul(it->second);
+ payload_->gather(content_length);
+ }
+ }
- virtual const HTTPPayload &getPayload() = 0;
+ HTTPPayload &&getPayload() { return std::move(payload_); }
- virtual const std::string &getHttpVersion() const = 0;
+ std::string getHttpVersion() const { return http_version_; };
protected:
HTTPHeaders headers_;