Skip to content
This repository has been archived by the owner on Feb 13, 2022. It is now read-only.

Add raw body storing #67

Closed
Arteneko opened this issue Oct 12, 2017 · 4 comments
Closed

Add raw body storing #67

Arteneko opened this issue Oct 12, 2017 · 4 comments

Comments

@Arteneko
Copy link

When using siler for a website, and assuming the request is only sent by a form using either application/x-www-form-urlencoded or multipart/form-data, PHP parses the request body and populates the $_POST variable with parse results.

If it doesn't recognise the Content-Type of the request or if it's incorrectly set, PHP will fail to parse without a warning and will only give an empty $_POST.

Such behaviour would be expected when using Siler as a backend API, receiving and sending back JSON (e.g. with the JSONP request format).

For that, the trick is to read from php://input but that can only be done 1 time (source). For now, the Request::raw method does the trick, but only one time.

I'll work on the Request.php file to add lazy retrieving/global storing to avoid data loss when reading multiple times.

@leocavalcante
Copy link
Owner

leocavalcante commented Oct 12, 2017

Hi @IvanDelsinne,
I didn't followed you. Can you show me some example about reading php://input just one time? What you mean by that?


Oh, ok, I see the notice now "Note: Prior to PHP 5.6, a stream opened with php://input could only be read once; the stream did not support seek operations.". Yeah, would be nice to have it in memory for further reading.

@Arteneko
Copy link
Author

I just noticed that it was only prior PHP5.6, so it was a mistake I made to think that it still worked that way. That'll teach me to read and test! (Actually I tested, but on an old PHP server we got at Uni, which is using PHP5.3).

Now I'm wondering... Should I implement it, to keep compatibility with such old versions or just close the issue and just keep this info. in my head ?

@leocavalcante
Copy link
Owner

leocavalcante commented Oct 13, 2017

Support for 5.5 ended in July 2016. I really don't think we should bother about compatibility with versions bellow 5.6.
And you should totally upgrade your server, not only for features, but mainly because security fixes hehe.

@Arteneko
Copy link
Author

Understood.

Also my servers are all using PHP7.1.8 and I'm painfully waiting for the PHP7.2 release, the server I was talking about is the server hosting most websites in our university and they use so much old stuff an update (even to PHP5.4) would break most of the website... (it's both sad and scary).

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

No branches or pull requests

2 participants