You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by be...@apache.org on 2015/07/15 17:41:56 UTC
thrift git commit: THRIFT-2858 Enable header field case insensitive
match in THttpServer Client: cpp Patch: Ben Craig
Repository: thrift
Updated Branches:
refs/heads/master 1f64ea959 -> 1abcbc721
THRIFT-2858 Enable header field case insensitive match in THttpServer
Client: cpp
Patch: Ben Craig <be...@apache.org>
Windows build works now
This closes #552
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/1abcbc72
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/1abcbc72
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/1abcbc72
Branch: refs/heads/master
Commit: 1abcbc721882bdb8fff3739487b518a0ccfefcb2
Parents: 1f64ea9
Author: ben-craig <be...@gmail.com>
Authored: Wed Jul 15 10:40:29 2015 -0500
Committer: ben-craig <be...@gmail.com>
Committed: Wed Jul 15 10:40:29 2015 -0500
----------------------------------------------------------------------
lib/cpp/src/thrift/transport/THttpServer.cpp | 17 ++++++++++++++---
lib/cpp/src/thrift/windows/config.h | 1 +
2 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/1abcbc72/lib/cpp/src/thrift/transport/THttpServer.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/THttpServer.cpp b/lib/cpp/src/thrift/transport/THttpServer.cpp
index 705e34a..a20d612 100644
--- a/lib/cpp/src/thrift/transport/THttpServer.cpp
+++ b/lib/cpp/src/thrift/transport/THttpServer.cpp
@@ -23,6 +23,9 @@
#include <thrift/transport/THttpServer.h>
#include <thrift/transport/TSocket.h>
+#ifdef _MSC_VER
+#include <Shlwapi.h>
+#endif
namespace apache {
namespace thrift {
@@ -36,6 +39,14 @@ THttpServer::THttpServer(boost::shared_ptr<TTransport> transport) : THttpTranspo
THttpServer::~THttpServer() {
}
+#ifdef _MSC_VER
+ #define THRIFT_strncasecmp(str1, str2, len) _strnicmp(str1, str2, len)
+ #define THRIFT_strcasestr(haystack, needle) StrStrIA(haystack, needle)
+#else
+ #define THRIFT_strncasecmp(str1, str2, len) strncasecmp(str1, str2, len)
+ #define THRIFT_strcasestr(haystack, needle) strcasestr(haystack, needle)
+#endif
+
void THttpServer::parseHeader(char* header) {
char* colon = strchr(header, ':');
if (colon == NULL) {
@@ -44,11 +55,11 @@ void THttpServer::parseHeader(char* header) {
size_t sz = colon - header;
char* value = colon + 1;
- if (strncasecmp(header, "Transfer-Encoding", sz) == 0) {
- if (strcasestr(value, "chunked") != NULL) {
+ if (THRIFT_strncasecmp(header, "Transfer-Encoding", sz) == 0) {
+ if (THRIFT_strcasestr(value, "chunked") != NULL) {
chunked_ = true;
}
- } else if (strncasecmp(header, "Content-length", sz) == 0) {
+ } else if (THRIFT_strncasecmp(header, "Content-length", sz) == 0) {
chunked_ = false;
contentLength_ = atoi(value);
} else if (strncmp(header, "X-Forwarded-For", sz) == 0) {
http://git-wip-us.apache.org/repos/asf/thrift/blob/1abcbc72/lib/cpp/src/thrift/windows/config.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/windows/config.h b/lib/cpp/src/thrift/windows/config.h
index dd0da35..24a94f8 100644
--- a/lib/cpp/src/thrift/windows/config.h
+++ b/lib/cpp/src/thrift/windows/config.h
@@ -94,5 +94,6 @@ typedef boost::uint8_t uint8_t;
#else
#pragma comment(lib, "Ws2_32.lib")
#pragma comment(lib, "advapi32.lib") // For security APIs in TPipeServer
+#pragma comment(lib, "Shlwapi.lib") // For StrStrIA in TPipeServer
#endif
#endif // _THRIFT_WINDOWS_CONFIG_H_