ArduinoHttpClient icon indicating copy to clipboard operation
ArduinoHttpClient copied to clipboard

reuse third-party C http_parser

Open proppy opened this issue 8 years ago • 7 comments

Have you considered reusing an existing http_parser?

The following imeplementation looks nice and embeddable: https://github.com/nodejs/http-parser/blob/master/http_parser.c

proppy avatar May 05 '17 06:05 proppy

@proppy what would be the advantages of using that parser? Would you be able to provide a pull request to use that parser for comparison?

This library is fairly slim and can run on AVR boards like the Uno.

sandeepmistry avatar May 10 '17 18:05 sandeepmistry

@sandeepmistry This parser looks well tested and used in production by many projects.

proppy avatar May 10 '17 19:05 proppy

@proppy let me phrase the question another way. Have you run into any issues with the parser built-into this library?

Do you have time to test out porting the parser into this Arduino library and comparing code size and memory usage with this library?

sandeepmistry avatar May 10 '17 19:05 sandeepmistry

@sandeepmistry I didn't went thru the path of porting the library to this parser. But a quick review of the code seems to indicate that it could perform better.

The current parser read byte "one by one": https://github.com/arduino-libraries/ArduinoHttpClient/blob/master/src/HttpClient.cpp#L613

While the http-parser implementation is capable of incrementally parsing byte buffers: https://github.com/nodejs/http-parser/blob/master/http_parser.h#L392

IIRC on "some arduino core" (ESP32, ESP8266) reading a byte could mean a context switch between the main task and another one handling the raw LWIP I/O. (summoning @igrr to confirm).

proppy avatar May 10 '17 19:05 proppy

Fair enough, in addition to comparing code size and memory usage, when could also compare throughput performance.

Just to be clear, this is would be low priority for the maintainers of this library. To really kick things off we'd need a pull request from a member of the community like yourself.

sandeepmistry avatar May 10 '17 19:05 sandeepmistry

Fair enough, in addition to comparing code size and memory usage, when could also compare throughput performance.

I think robustness and feature parity could also be a factor. There is always a trade-off when re implementing something as complex as an HTTP parser yourself.

proppy avatar May 10 '17 19:05 proppy

Any progress so far?

ricardoboss avatar Jul 21 '17 15:07 ricardoboss