-AM_CPPFLAGS=$(BOOST_CPPFLAGS)
-
+AM_CPPFLAGS=$(BOOST_CPPFLAGS) @THREADFLAGS@
noinst_LTLIBRARIES=libyahttp.la
libyahttp_la_SOURCES=cookie.hpp exception.hpp reqresp.cpp reqresp.hpp router.cpp router.hpp url.hpp utility.hpp yahttp-config.h yahttp.hpp
+
+yahttp-config.h:
+ cat ../../../../config.h > yahttp-config.h
minbody = 0;
// check for expected body size
- if (target->kind == YAHTTP_TYPE_REQUEST) maxbody = YAHTTP_MAX_REQUEST_SIZE;
- else if (target->kind == YAHTTP_TYPE_RESPONSE) maxbody = YAHTTP_MAX_RESPONSE_SIZE;
+ if (target->kind == YAHTTP_TYPE_REQUEST) maxbody = target->max_request_size;
+ else if (target->kind == YAHTTP_TYPE_RESPONSE) maxbody = target->max_response_size;
else maxbody = 0;
if (!chunked) {
maxbody = minbody;
}
if (minbody < 1) return true; // guess there isn't anything left.
- if (target->kind == YAHTTP_TYPE_REQUEST && minbody > YAHTTP_MAX_REQUEST_SIZE) throw ParseError("Max request body size exceeded");
- else if (target->kind == YAHTTP_TYPE_RESPONSE && minbody > YAHTTP_MAX_RESPONSE_SIZE) throw ParseError("Max response body size exceeded");
+ if (target->kind == YAHTTP_TYPE_REQUEST && minbody > target->max_request_size) throw ParseError("Max request body size exceeded");
+ else if (target->kind == YAHTTP_TYPE_RESPONSE && minbody > target->max_response_size) throw ParseError("Max response body size exceeded");
}
if (maxbody == 0) hasBody = false;
#ifdef HAVE_CPP_FUNC_PTR
renderer = SendBodyRender();
#endif
+ max_request_size = YAHTTP_MAX_REQUEST_SIZE;
+ max_response_size = YAHTTP_MAX_RESPONSE_SIZE;
};
protected:
HTTPBase(const HTTPBase& rhs) {
std::string routeName; //<! name of the current route (only if you use YaHTTP::Router)
std::string body; //<! the actual content
+
+ ssize_t max_request_size; //<! maximum size of request
+ ssize_t max_response_size; //<! maximum size of response
#ifdef HAVE_CPP_FUNC_PTR
funcptr::function<size_t(const HTTPBase*,std::ostream&)> renderer; //<! rendering function
struct tm tm;
localtime_r(&t, &tm);
fromTm(&tm);
+#ifndef HAVE_TM_GMTOFF
+ time_t t2 = timegm(&tm);
+#endif
#else
struct tm *tm;
tm = localtime(&t);
fromTm(tm);
+#ifndef HAVE_TM_GMTOFF
+ time_t t2 = timegm(tm);
+#endif
+#endif
+#ifndef HAVE_TM_GMTOFF
+ this->utc_offset = ((t2-t)/10)*10; // removes any possible differences.
#endif
}; //<! uses localtime for time
struct tm *tm;
tm = gmtime(&t);
fromTm(tm);
+#endif
+#ifndef HAVE_TM_GMTOFF
+ this->utc_offset = 0;
#endif
}; //<! uses gmtime for time
wday = tm->tm_wday;
#ifdef HAVE_TM_GMTOFF
utc_offset = tm->tm_gmtoff;
-#else
- utc_offset = 0;
#endif
isSet = true;
}; //<! parses date from struct tm
void parse822(const std::string &rfc822_date) {
struct tm tm;
- if ( (strptime(rfc822_date.c_str(), "%a, %d %b %Y %T %z", &tm)) != NULL) {
+ const char *ptr;
+#ifdef HAVE_TM_GMTOFF
+ if ( (ptr = strptime(rfc822_date.c_str(), "%a, %d %b %Y %T %z", &tm)) != NULL) {
+#else
+ if ( (ptr = strptime(rfc822_date.c_str(), "%a, %d %b %Y %T", &tm)) != NULL) {
+ int sign;
+ // parse the timezone parameter
+ while(*ptr && ::isspace(*ptr)) ptr++;
+ if (*ptr == '+') sign = 0;
+ else if (*ptr == '-') sign = -1;
+ else throw "Unparseable date";
+ ptr++;
+ utc_offset = ::atoi(ptr) * sign;
+ while(*ptr && ::isdigit(*ptr)) ptr++;
+#endif
+ while(*ptr && ::isspace(*ptr)) ptr++;
+ if (*ptr) throw "Unparseable date"; // must be final.
fromTm(&tm);
} else {
throw "Unparseable date";
}
}; //<! parses HTTP Cookie date
- int unixtime() const {
+ time_t unixtime() const {
struct tm tm;
tm.tm_year = year-1900;
tm.tm_mon = month-1;
#ifdef HAVE_TM_GMTOFF
tm.tm_gmtoff = utc_offset;
#endif
- return mktime(&tm);
+ return timelocal(&tm);
}; //<! returns this datetime as unixtime. will not work for dates before 1970/1/1 00:00:00 GMT
};