Skip to content

Commit 828c334

Browse files
Add additional fields to NetworkResponse (#764)
Add the information about number of bytes downloaded/uploaded. Relates-To: OLPEDGE-1761 Signed-off-by: Mykhailo Kuchma <[email protected]>
1 parent 7e9b1a7 commit 828c334

File tree

2 files changed

+70
-2
lines changed

2 files changed

+70
-2
lines changed

olp-cpp-sdk-core/include/olp/core/http/NetworkResponse.h

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,59 +34,110 @@ class CORE_API NetworkResponse final {
3434
public:
3535
/**
3636
* @brief Check if associated request was cancelled.
37+
*
3738
* @return true if associated request was cancelled.
3839
*/
3940
bool IsCancelled() const;
4041

4142
/**
4243
* @brief Get HTTP response code.
44+
*
4345
* @return HTTP response code.
4446
*/
4547
int GetStatus() const;
4648

4749
/**
4850
* @brief Set HTTP response code.
51+
*
4952
* @param[in] status HTTP response code.
53+
*
5054
* @return reference to *this.
5155
*/
5256
NetworkResponse& WithStatus(int status);
5357

5458
/**
5559
* @brief Get human-readable error message in case of failed associated
5660
* request.
61+
*
5762
* @return human-readable error message in case of failed associated request.
5863
*/
5964
const std::string& GetError() const;
6065

6166
/**
6267
* @brief Set human-readable error message in case of failed associated
6368
* request.
69+
*
6470
* @param[in] error Human-readable error message in case of failed
6571
* associated request.
72+
*
6673
* @return reference to *this.
6774
*/
6875
NetworkResponse& WithError(std::string error);
6976

7077
/**
7178
* @brief Get id of associated network request.
79+
*
7280
* @return id of associated network request.
7381
*/
7482
RequestId GetRequestId() const;
7583

7684
/**
7785
* @brief Set id of associated network request.
86+
*
7887
* @param[in] id Id of associated network request.
88+
*
7989
* @return reference to *this.
8090
*/
8191
NetworkResponse& WithRequestId(RequestId id);
8292

93+
/**
94+
* @brief Get the number of bytes uploaded during the associated network
95+
* request.
96+
*
97+
* @return The number of bytes uploaded during the associated network request.
98+
*/
99+
uint64_t GetBytesUploaded() const;
100+
101+
/**
102+
* @brief Set the number of bytes uploaded during the associated network
103+
* request.
104+
*
105+
* @param[in] bytes_uploaded Number of uploaded bytes.
106+
*
107+
* @return reference to *this.
108+
*/
109+
NetworkResponse& WithBytesUploaded(uint64_t bytes_uploaded);
110+
111+
/**
112+
* @brief Get the number of bytes downloaded during the associated network
113+
* request.
114+
*
115+
* @return The number of bytes downloaded during the associated network
116+
* request.
117+
*/
118+
uint64_t GetBytesDownloaded() const;
119+
120+
/**
121+
* @brief Set the number of bytes downloaded during the associated network
122+
* request.
123+
*
124+
* @param[in] bytes_downloaded Number of downloaded bytes.
125+
*
126+
* @return reference to *this.
127+
*/
128+
NetworkResponse& WithBytesDownloaded(uint64_t bytes_downloaded);
129+
83130
private:
84131
/// Associated request id.
85132
RequestId request_id_{0};
86133
/// HTTP response code.
87134
int status_{0};
88135
/// Human-readable error message in case of failed associated request.
89136
std::string error_;
137+
/// Number of bytes uploaded during network request.
138+
uint64_t bytes_uploaded_;
139+
/// Number of bytes downloaded during network request.
140+
uint64_t bytes_downloaded_;
90141
};
91142

92143
} // namespace http

olp-cpp-sdk-core/src/http/NetworkResponse.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019 HERE Europe B.V.
2+
* Copyright (C) 2019-2020 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,5 +48,22 @@ NetworkResponse& NetworkResponse::WithRequestId(RequestId id) {
4848
return *this;
4949
}
5050

51+
uint64_t NetworkResponse::GetBytesUploaded() const { return bytes_uploaded_; }
52+
53+
NetworkResponse& NetworkResponse::WithBytesUploaded(uint64_t bytes_uploaded) {
54+
bytes_uploaded_ = bytes_uploaded;
55+
return *this;
56+
}
57+
58+
uint64_t NetworkResponse::GetBytesDownloaded() const {
59+
return bytes_downloaded_;
60+
}
61+
62+
NetworkResponse& NetworkResponse::WithBytesDownloaded(
63+
uint64_t bytes_downloaded) {
64+
bytes_downloaded_ = bytes_downloaded;
65+
return *this;
66+
}
67+
5168
} // namespace http
5269
} // namespace olp

0 commit comments

Comments
 (0)