From 536feb632ce13f460e4e0406f33664fb1253425d Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Wed, 8 Jun 2016 15:09:09 -0700 Subject: [PATCH] Support yet another old version of http-parser for CentOS/EPEL. --- osdep/Http.cpp | 13 +++++++++++++ osdep/Phy.hpp | 4 ++-- service/OneService.cpp | 13 +++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/osdep/Http.cpp b/osdep/Http.cpp index 4fe298b30..064ccd0c4 100644 --- a/osdep/Http.cpp +++ b/osdep/Http.cpp @@ -48,6 +48,8 @@ static int ShttpOnValue(http_parser *parser,const char *ptr,size_t length); static int ShttpOnHeadersComplete(http_parser *parser); static int ShttpOnBody(http_parser *parser,const char *ptr,size_t length); static int ShttpOnMessageComplete(http_parser *parser); + +#if (HTTP_PARSER_VERSION_MAJOR >= 2) && (HTTP_PARSER_VERSION_MINOR >= 1) static const struct http_parser_settings HTTP_PARSER_SETTINGS = { ShttpOnMessageBegin, ShttpOnUrl, @@ -58,6 +60,17 @@ static const struct http_parser_settings HTTP_PARSER_SETTINGS = { ShttpOnBody, ShttpOnMessageComplete }; +#else +static const struct http_parser_settings HTTP_PARSER_SETTINGS = { + ShttpOnMessageBegin, + ShttpOnUrl, + ShttpOnHeaderField, + ShttpOnValue, + ShttpOnHeadersComplete, + ShttpOnBody, + ShttpOnMessageComplete +}; +#endif struct HttpPhyHandler { diff --git a/osdep/Phy.hpp b/osdep/Phy.hpp index 03eb84c2f..1b08f30aa 100644 --- a/osdep/Phy.hpp +++ b/osdep/Phy.hpp @@ -252,7 +252,7 @@ public: #if defined(_WIN32) || defined(_WIN64) ::send(_whackSendSocket,(const char *)this,1,0); #else - (void)::write(_whackSendSocket,(PhySocket *)this,1); + (void)(::write(_whackSendSocket,(PhySocket *)this,1)); #endif } @@ -871,7 +871,7 @@ public: #if defined(_WIN32) || defined(_WIN64) ::recv(_whackReceiveSocket,tmp,16,0); #else - (void)::read(_whackReceiveSocket,tmp,16); + (void)(::read(_whackReceiveSocket,tmp,16)); #endif } diff --git a/service/OneService.cpp b/service/OneService.cpp index a5e49f366..39449cab9 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -416,6 +416,8 @@ static int ShttpOnValue(http_parser *parser,const char *ptr,size_t length); static int ShttpOnHeadersComplete(http_parser *parser); static int ShttpOnBody(http_parser *parser,const char *ptr,size_t length); static int ShttpOnMessageComplete(http_parser *parser); + +#if (HTTP_PARSER_VERSION_MAJOR >= 2) && (HTTP_PARSER_VERSION_MINOR >= 1) static const struct http_parser_settings HTTP_PARSER_SETTINGS = { ShttpOnMessageBegin, ShttpOnUrl, @@ -426,6 +428,17 @@ static const struct http_parser_settings HTTP_PARSER_SETTINGS = { ShttpOnBody, ShttpOnMessageComplete }; +#else +static const struct http_parser_settings HTTP_PARSER_SETTINGS = { + ShttpOnMessageBegin, + ShttpOnUrl, + ShttpOnHeaderField, + ShttpOnValue, + ShttpOnHeadersComplete, + ShttpOnBody, + ShttpOnMessageComplete +}; +#endif struct TcpConnection {