Skip to content

Add getFieldValue() to Body Parser #83

Open
@fhessel

Description

@fhessel

Is your feature request related to a problem? Please describe.

The body parsers (at least the one for URL-encoded bodies) should provide a getFieldValue() shortcut that returns the complete value of a field. That makes handling small forms easier.

Describe the solution you'd like

Instead of this code:

char buf[512];
size_t bufIdx = 0;
while (!parser.endOfField() || bufId >= 512) {
  size_t readLength = parser.read(buf[bufIdx], 512);
  bufIdx += readLength;
}
std::string fieldValue = std::string(buf, bufIdx);

This shortcut would be nice:

std::string fieldValue = parser.getFieldValue();

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions