-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Creating a buffer for parseHeader and parsePostData #622
Conversation
any comments so far? |
do | ||
{ | ||
nextLine = NetUtils::pbufFindStr(buf, "\r\n", line); | ||
|
||
nextLine = tmpbuf.indexOf("\r\n", line+2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the last parenthesis be placed before the "+" operator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I`ll verify it again
No comments regarding coding style since I found no reference to the style adopted by this project. Linux Kernel style is the most common for this kind of projects and this PR doesn't conform in several places. |
See the Summary on the first page - there is the compatibility listed to arduino libraries ... In regards to processing packets as they arrive (actually you can relate to this as a concept of processing a stream) - it is more memory friendly. While header data might be "small" (compared to post requests) - it requires more ram than just keeping unprocessed packet data in a buffer. Before this PR there was no processing of headers split accross packets - (see #615 ) |
Not sure if the comment is related to the coding style or discussion about the substring function.
It is not obvious to me how that is true. You are trading raw data buffer space with hash stored values which looking at the implementation bloats the amount of memory needed to store the data (which is true for all hash implementations).
No argument there. It is obvious there was a bug, the data will need to be appended to a buffer between callback calls or it will get ditched.
Why not? You can just buffer the stream until you find "delimiter "--"" and parse it then. In the end your code should work fine (although I still think you have a misplaced parenthesis), it is just a matter of personal coding style. Long do/whiles and lots of global variables are not my thing, also I found this PR hard to read not only by the code style but also by the variable naming. |
It was related to the discussion in regards to substring and compatibility with arduino libraries. And as suggested - i think this is best suited to be discussed in it`s own issue since it is not related to this PR
You need to differentiate between the buffer and the Hashmap - the Hashmap implementation was already in use even before I suggested the buffer. When keeping everything in one buffer before parsing, you would need the space for the buffer and the hashmap at the same time. Parsing as far as it goes, the buffer data needed can be smaller and leave room for the final hashmap to be worked with.
Since multipart requests are not only variables/fields to be kept in memory, but also can be files - I don`t see your suggestion viable - it would need again 2 different implementations for one task. For suggestions/discussion on multipart and file uploads please join #552
Please compare the version before and after my PR - I based my solution on the already exiting coding style. In what way would you improve the current implementation ?
I hope you don |
On In the PR now there is
|
I had trouble squashing - will try again later and update accordingly. Please wait with merging until then. I still want to verify the part with the misplaced parenthesis - didn`t get around to it until now |
OK Clear |
144e770
to
ed66036
Compare
@PTDreamer @hreintke |
@avr39-ripe |
Nither queryParameter nor urlencoded form data DO NOT work ;(( switching to regular sming/develop solve the problem.. and introduce new one with packet hassle |
pushed the proposed fix - please test and confirm that query and post parameters are working now as expected (please test only this branch and don`t include rawbody yet) |
cherry-pick last two commits on top of develop and it works. tested by using response.getQueryParameter(). Thanks! |
I`d say this is ready to merge - maybe someone else can also confirm ?
|
If @dobrishinov try this and confirm.. He expect problems with split/truncated data.. but it needs rawBody fix also.. |
This addresses #615 and also prepares for working on multipart requests
The previous implementation did not account that header information could be split between several packets. Also post data can be split across several TCP packets.
The changes address this by storing not processed data in a temporary buffer and pre pending the new tcp buffer so it will be parsed together
Has been tested with several requests (GET/POST including Cookies and large headers)