You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@milagro.apache.org by sa...@apache.org on 2016/09/17 13:05:06 UTC
[05/11] incubator-milagro-mfa-sdk-ios git commit: add User-Agent
field to http header
add User-Agent field to http header
Project: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-sdk-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-sdk-ios/commit/53f1ebbb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-sdk-ios/tree/53f1ebbb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-sdk-ios/diff/53f1ebbb
Branch: refs/heads/master
Commit: 53f1ebbb5223d0ef00d0800c36b25bedec35dc5e
Parents: d335af0
Author: georgi.georgiev <ge...@certivox.com>
Authored: Fri Sep 2 14:46:00 2016 +0300
Committer: georgi.georgiev <ge...@certivox.com>
Committed: Fri Sep 2 14:46:00 2016 +0300
----------------------------------------------------------------------
src/HTTPConnector.mm | 12 ++++++++++++
1 file changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-milagro-mfa-sdk-ios/blob/53f1ebbb/src/HTTPConnector.mm
----------------------------------------------------------------------
diff --git a/src/HTTPConnector.mm b/src/HTTPConnector.mm
index 21e7873..7acb724 100644
--- a/src/HTTPConnector.mm
+++ b/src/HTTPConnector.mm
@@ -19,6 +19,7 @@
#include "HTTPConnector.h"
#import "MPin.h"
+#import <UIKit/UIKit.h>
static NSInteger constIntTimeoutInterval = 30;
static NSString *constStrConnectionTimeoutNotification = @"ConnectionTimeoutNotification";
@@ -101,6 +102,17 @@ namespace net {
[request addValue:@"ios" forHTTPHeaderField:@"X-MIRACL-OS-Class"];
+ NSDictionary *dictInfo = [[NSBundle mainBundle] infoDictionary];
+ NSString *strBundleID = dictInfo[@"CFBundleIdentifier"];
+ NSString *strAppVersion = dictInfo[@"CFBundleShortVersionString"];
+ NSString *strOSVersion = [[UIDevice currentDevice] systemVersion];
+ NSString *strBuildNumber = dictInfo[@"CFBundleVersion"];
+
+ NSString *strUserAgent = [NSString stringWithFormat:@"%@/%@ (ios/%@) build/%@",strBundleID,strAppVersion,strOSVersion, strBuildNumber];
+
+ [request setValue:strUserAgent forHTTPHeaderField:@"User-Agent"];
+
+
if(!m_bodyData.empty()) {
request.HTTPBody = [[NSString stringWithUTF8String:m_bodyData.c_str()] dataUsingEncoding:NSUTF8StringEncoding];
}