#define pretty_key(key, key_len, uctitle, xhyphen) _http_pretty_key(key, key_len, uctitle, xhyphen)
extern char *_http_pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool xhyphen);
-#define http_parse_cookie(l, i) _http_parse_cookie((l), (i) TSRMLS_CC)
-PHP_HTTP_API STATUS _http_parse_cookie(const char *list, HashTable *items TSRMLS_DC);
-
#define http_error(type, code, string) _http_error_ex(type, code, "%s", string)
#define http_error_ex _http_error_ex
extern void _http_error_ex(long type TSRMLS_DC, long code, const char *format, ...);
#define http_locate_body _http_locate_body
static inline const char *_http_locate_body(const char *message)
{
- const char *cr = strstr(message, "\r\n\r\n");
- const char *lf = strstr(message, "\n\n");
-
- if (lf && cr) {
- return MIN(lf + 2, cr + 4);
- } else if (lf || cr) {
- return MAX(lf + 2, cr + 4);
- } else {
- return NULL;
+ const char *body = NULL, *msg = message;
+
+ while (*msg) {
+ if (*msg == '\n') {
+ if (*(msg+1) == '\n') {
+ body = msg + 2;
+ break;
+ } else if (*(msg+1) == '\r' && *(msg+2) == '\n' && msg != message && *(msg-1) == '\r') {
+ body = msg + 3;
+ break;
+ }
+ }
+ ++msg;
}
+ return body;
}
#define http_locate_eol _http_locate_eol