Comments (16)
Hello,
has there been any updates on this issue?
I am currently trying to access binary data send using the POST.
(curl -v -0 -X POST "http://MYTESTHOST:8080/v2/updown" -H "accept: application/octet-stream" -H "Content-Type: multipart/form-data" -F "[email protected]" -F "foo=bar")
I can print the body but not access the data.
Thank you very much in advance.
from pistache.
+1
from pistache.
Hello.
You're right, currently, the API does not provide a way to access the POST parameters of a request other than getting the request.body()
and parsing the parameters yourself.
I think that it might be a great addition to the API and will think about it.
from pistache.
+1. It would be indeed a great feature.
from pistache.
+1
from pistache.
+1
from pistache.
+1
from pistache.
I think a middleware infrastructure could be a good approach once you could create custom parsers based on content type.
from pistache.
Did anyone find out how to parse the post paremeters. I have a situation where multiple paremeters are being sent including binary, but can't work out how to parse the string effectively.
from pistache.
I found out that you can post using json and use the nlohmann json library to parse the data, if that helps anyone.
from pistache.
@oktal wrote:
Hello.
You're right, currently, the API does not provide a way to access the POST parameters of a request other than getting the
request.body()
and parsing the parameters yourself.I think that it might be a great addition to the API and will think about it.
Agreed, but only the API should be extended. We already have a parameter parser:
https://github.com/oktal/pistache/blob/5752d4b1d6eb5171e15128171496b4c3f91c44ca/src/common/http.cc#L156-L188
I think that the parameter parser could somehow be extracted and be re-used to parse the request.body ()
, in case of a POST.
from pistache.
I think that the parameter parser could somehow be extracted and be re-used to parse the request.body (), in case of a POST.
A closer look at the parser mentioned, showed that it will have to be modified a bit. The POST/PUT body parser should be capable of parse quoted (and possibly chunked) data, so using flex and bison might slowly start being a good option. Would the use of flex and bison for all parsing, throughout this lib, not be the way to go?
from pistache.
The last time I checked (its been a long time), flex and bison did not create re-entrant, thread-safe or c++ "clean" parsers. If someone really wants a complex parser in pistache, I suggest that you look at using the "lemon parser" from the sqlite project.
from pistache.
@dennisjenkins75
Hi Dennis,
for file operations, i need to get the file content that sent by browser, not i can get the body message how can i extract the file part ? is it supported by Pistache ?
the example body of my request :
----WebKitFormBoundarymANHtRsFm42ZLFBC^M
Content-Disposition: form-data; name="file"; filename="favicon.ico"^M
Content-Type: image/x-icon^M
^M
a½[±ÔÆ£AÕn¯XmS£ª[Ä^MÕ½)ã¬<80>ã/Xt¦°bÅÐO«ÅV^R¤L³{^M~<8f><82>´^?ïòå]ê_D$"ãëd©óÚÑ¥KXÁ§À 8^A<96>O^FXûÒÀ^R^]^AËï(XAÙ
<85>æ<83>^UQ^LU^Bf¢¶Í"UMG<^U÷¤^BêOh<90>k^W\ê^?·,<9f>´biÿ¢ãç^T¿<98>:§<95>R£¦^V
------WebKitFormBoundarymANHtRsFm42ZLFBC--^M
from pistache.
Pistache provides no direct support for parsing MIME requests. You'll need to use a mime parser (some other library) or write your own. I recommend using an existing library. However, I do not have any actual recommendations, as I've not needed to parse MIME in a long time.
from pistache.
Yes, actually I reviewed the Pistache code and I can not find any MIME parser, also I searched for the fast, light weight and high performance low memory for MIME parser, but I can not find any, there are some MIME encoders but for decoder part the CGICC or FastCgi provide some, there were full MIME parser, and most part of them are implemented for mail message and also written in C, there were not fit to my usage, and also there were very complicated, I do not really parse all Content-Types, I only need to get binary files and formdata values, I am writing my own, file and formdata types are most used in HTTP servers, and cover more than 90% of all requests, the file part is most important part, once I finished and optimized my code will share with you as a PR, if you are interested in, you can merge, and the others people can use it as a part of Pistache to cover formdata, and file content types.
from pistache.
Related Issues (20)
- build error with latest master HOT 2
- could you add more examples?
- makefile build error
- Failed to build with GCC 13 HOT 5
- Pistache not support absolute URI with HTTP/1.1 protocol
- [Feature Request] Integrating compression in ResponseWriter (Brotli, gzip, and deflate) HOT 12
- My REST API server just crashes leaving no backtrace HOT 5
- Unit testing of individual routes/path - Too many responsibilities of Pistache::Http::ResponseWriter HOT 1
- Swagger UI CORS problem
- Crashed with std::runtime_error - bad file descriptor HOT 11
- Data race in Pistache::Http::Experimental::Client HOT 2
- Want to contribute by building the documentation site for pistache HOT 2
- Getting SIGILL with gcc12 HOT 11
- Memory corruption when using the server in multi-threaded mode. HOT 6
- serveFile crashes if passed-by-reference fileName parameter goes out of scope HOT 8
- WriteEntry Constructor called with Incorrect Parameters in Transport::asyncWriteImpl
- [BUG] ResponseWriter::setCompression() chokes on identity encoding
- [BUG] Fails to fetch build dependencies in autopkgtest HOT 7
- [BUG] All PPA builds failing due to missing zlib headers
- [BUG] New compression code fails to build on armhf HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pistache.