Skip to content

Add getFieldValue() to Body Parser #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fhessel opened this issue Apr 13, 2020 · 0 comments
Open

Add getFieldValue() to Body Parser #83

fhessel opened this issue Apr 13, 2020 · 0 comments
Labels

Comments

@fhessel
Copy link
Owner

fhessel commented Apr 13, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant