Beast: How to retrieve POST query parameters?

Created on 14 May 2020  路  6Comments  路  Source: boostorg/beast

Hey all, i have a server and client using beast/http
have some way available to retrieve POST query parameters in server side or i need to implement it my self?

Client:

req.set(beast::http::field::content_type, "application/x-www-form-urlencoded");
req.body() = "login=someUser&password=somePass";
req.prepare_payload();

Server:

// The question is here, the library provides some way to receive the parameters,
// or I need to create a specific method for that, such as a split from some delimiter
req.body().data()

All 6 comments

Processing form data is a higher level concern than boost covers.

Boost covers the HTTP (hypertext _transport_ protocol) and the websocket protocol.

The semantics of GET/POST etc are a higher level concern.

As things stand you will need to parse the form data yourself.

I understand, that's what I've been doing, thanks for the information.

Keep an eye out for this later in the year: https://github.com/vinniefalco/url

In the meantime you might have a look at the URI helper from the CPPRestSDK. Stripping it out as standalone helper is easy, I鈥榤 using it with Beast for about a year without problems.

[1] https://github.com/microsoft/cpprestsdk/blob/master/Release/src/uri/uri.cpp

Closing this issue as answered. If you have any more questions, please don't hesitate to ask.
We live in the #beast channel of cpplang slack (but please read the manual before asking questions there).

Was this page helpful?
0 / 5 - 0 ratings