Giter VIP home page Giter VIP logo

Comments (16)

MaxKrueger avatar MaxKrueger commented on May 3, 2024 2

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.

atonkyra avatar atonkyra commented on May 3, 2024

+1

from pistache.

oktal avatar oktal commented on May 3, 2024

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.

hoang408 avatar hoang408 commented on May 3, 2024

+1. It would be indeed a great feature.

from pistache.

bigerl avatar bigerl commented on May 3, 2024

+1

from pistache.

msoodb avatar msoodb commented on May 3, 2024

+1

from pistache.

qiutianme avatar qiutianme commented on May 3, 2024

+1

from pistache.

arthurafarias avatar arthurafarias commented on May 3, 2024

I think a middleware infrastructure could be a good approach once you could create custom parsers based on content type.

from pistache.

Asimov500 avatar Asimov500 commented on May 3, 2024

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.

Asimov500 avatar Asimov500 commented on May 3, 2024

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.

wingunder avatar wingunder commented on May 3, 2024

@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.

wingunder avatar wingunder commented on May 3, 2024

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.

dennisjenkins75 avatar dennisjenkins75 commented on May 3, 2024

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.

mohsenomidi avatar mohsenomidi commented on May 3, 2024

@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.

dennisjenkins75 avatar dennisjenkins75 commented on May 3, 2024

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.

mohsenomidi avatar mohsenomidi commented on May 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.