Turns out some servers may send line feeds and carriage return after the final
boundary. That's the case for the following WebKit LayoutTest:
http/tests/multipart/load-last-non-html-frame.php
https://bugzilla.gnome.org/show_bug.cgi?id=685752
got_boundary = TRUE;
/* Now check for possible multipart termination. */
- buf = &read_buf[nread - 2];
- if (nread >= 2 && !memcmp (buf, "--", 2)) {
+ buf = &read_buf[nread - 4];
+ if ((nread >= 4 && !memcmp (buf, "--\r\n", 4)) ||
+ (nread >= 3 && !memcmp (buf + 1, "--\n", 3)) ||
+ (nread >= 3 && !memcmp (buf + 2, "--", 2))) {
g_byte_array_set_size (priv->meta_buf, 0);
return FALSE;
}