Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions lib/cpp/src/thrift/transport/THttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions lib/cpp/src/thrift/windows/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_