summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2016-07-01 15:30:56 -0400
committerJackLivio <jack@livio.io>2016-07-01 15:30:56 -0400
commitc085490eff7469bbf284c09ddcbdd749ce2819a1 (patch)
treecd97b0d4d78a13b431addb215db9515cc87babfd
parent657eec2f9a373c84cf2c381376737cffc0b46f78 (diff)
downloadsdl_core-hotfix/fix_request_header_typo_and_content_length_calculation.tar.gz
Changed ParsePTString() to return the calculated content lengthhotfix/fix_request_header_typo_and_content_length_calculation
-rw-r--r--src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h2
-rw-r--r--src/components/application_manager/src/commands/mobile/on_system_request_notification.cc13
2 files changed, 8 insertions, 7 deletions
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h b/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h
index 86862f8b04..cba6c4ed99 100644
--- a/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h
+++ b/src/components/application_manager/include/application_manager/commands/mobile/on_system_request_notification.h
@@ -72,7 +72,7 @@ class OnSystemRequestNotification : public CommandNotificationImpl {
* @param message Message
*/
void AddHeader(BinaryMessage& message) const;
- void ParsePTString(std::string& pt_string, size_t& contentLength) const;
+ size_t ParsePTString(std::string& pt_string) const;
#endif
DISALLOW_COPY_AND_ASSIGN(OnSystemRequestNotification);
diff --git a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
index 1a37fd04d6..166a4b7736 100644
--- a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
+++ b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc
@@ -106,7 +106,7 @@ void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const {
LOG4CXX_AUTO_TRACE(logger_);
const int timeout = policy::PolicyHandler::instance()->TimeoutExchange();
- size_t contentLength;
+ size_t content_length;
char size_str[24];
char timeout_str[24];
@@ -120,11 +120,10 @@ void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const {
calculated before additional escape characters are added to the
policy table string. The mobile proxy will remove the escape
characters after receiving this request. */
- contentLength = policy_table_string.length();
- ParsePTString(policy_table_string, contentLength);
+ content_length = ParsePTString(policy_table_string);
- if (0 > sprintf(size_str, "%zu", contentLength)) {
+ if (0 > sprintf(size_str, "%zu", content_length)) {
memset(size_str, 0, sizeof(size_str));
}
@@ -155,20 +154,22 @@ void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const {
logger_, "Header added: " << std::string(message.begin(), message.end()));
}
-void OnSystemRequestNotification::ParsePTString(std::string& pt_string, size_t& contentLength) const{
+size_t OnSystemRequestNotification::ParsePTString(std::string& pt_string) const{
std::string result;
size_t length = pt_string.length();
+ size_t result_length = length;
result.reserve(length*2);
for(size_t i=0;i<length;++i){
if(pt_string[i]=='\"' || pt_string[i]=='\\'){
result += '\\';
} else if(pt_string[i] == '\n') {
- contentLength--; // contentLength is adjusted when this character is not copied to result.
+ result_length--; // contentLength is adjusted when this character is not copied to result.
continue;
}
result += pt_string[i];
}
pt_string = result;
+ return result_length;
}
#endif