Skip to content

[esp_http_client]: HTTP readline support (IDFGH-14938) #15647

Open
@bryghtlabs-richard

Description

@bryghtlabs-richard

Is your feature request related to a problem?

No, just an idea to make line-based server-push HTTP parsing simpler.

Describe the solution you'd like.

I'd like a delimited equivalent of int esp_http_client_read_response(), where I could specify a delimiter(or just use newline). Upon finding the delimiter or length-limit, the function would return.

This would make implementing HTTP chunked push-based streaming protocols like NDJSON/LDJSON/JSONL, stock-ticker type APIs, CSV, and other line-based formats simpler.

Describe alternatives you've considered.

It isn't a difficult thing to write, but I find myself repeating the implementation. Here are some approaches without changing esp_http_client

Option1: esp_http_client_read(len=1) and appending to line-buffer until a newline is found, then parsing the line, then resetting the buffer-index.
Option2: esp_http_client_read(large fixed buffer), then finding the newline, parsing the line, shifting the buffer over to erase the previous line, repeating.

Additional context.

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions