-#define http_split_response(r, rl, h, b, bl) _http_split_response((r), (rl), (h), (b), (bl) TSRMLS_CC)
-PHP_HTTP_API STATUS _http_split_response(char *response, size_t repsonse_len, HashTable *headers, char **body, size_t *body_len TSRMLS_DC);
+#define http_guess_content_type(mf, mm, d, l, m) _http_guess_content_type((mf), (mm), (d), (l), (m) TSRMLS_CC)
+PHP_HTTP_API char *_http_guess_content_type(const char *magic_file, long magic_mode, void *data_ptr, size_t data_len, http_send_mode mode TSRMLS_DC);
+
+
+#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;
+ }
+}
+
+#define http_locate_eol _http_locate_eol
+static inline const char *_http_locate_eol(const char *line, size_t *eol_len)
+{
+ const char *eol = strpbrk(line, "\r\n");
+
+ if (eol_len) {
+ *eol_len = eol ? ((eol[0] == '\r' && eol[1] == '\n') ? 2 : 1) : 0;
+ }
+ return eol;
+}