Rewrite multipart boundary detection by earlephilhower · Pull Request #7728 · esp8266/Arduino

@earlephilhower

Use a simpler, cleaner implementation of multipart form detection as
defined in https://tools.ietf.org/html/rfc7578 .

Implements a simple state machine that detects the \r\n--<boundary>
stream in input a character at a time, instead of buffering and
comparing in chunks which can miss things due to alignment issues and
which also had a problem with replacing characters in a binary stream.

Fixes esp8266#7723

d-a-v

@earlephilhower

Adjust the private _uploadReadByte function to return -1 on error (like
a read()), and the main file upload handler to use that return value
instead of duplicating logic.

@earlephilhower