php-crud-api icon indicating copy to clipboard operation
php-crud-api copied to clipboard

Compressed (gzip) PUT and POST request body

Open lnjuanj opened this issue 6 years ago • 3 comments

Hi, First of all, this API is amazing! One single file and so much power :) I would like to send compressed gzip content through POST and PUT requests (I send posts with tens or hundreds of objects, hence compression would be a great feature). I see the API does not support this by default. How do you recommend doing this? I guess the best thing would be checking the headers and if 'Content-Encoding' contains 'gzip' --> uncompress before managing the data. I would like to:

  • Either introduce this into my config file
  • Have it in the php-crud-api repo. Otherwise, I would have a library/file that could not be updated anymore as easily. I thought I could use the 'before' function but I see I wouldn't have access to the headers from there. Please advice me about this. Thanks!

lnjuanj avatar Apr 12 '18 08:04 lnjuanj

I would like to send compressed gzip content through POST and PUT requests

Sounds like a good feature request.

I guess the best thing would be checking the headers

Probably not needed. This should be easily detectable from the input data itself based on the first two bytes (a magic number):

a 10-byte header, containing a magic number (1f 8b), compression id, file flags, a timestamp, compression flags and operating system id.

See: https://en.wikipedia.org/wiki/Gzip

mevdschee avatar Apr 12 '18 21:04 mevdschee

@mevdschee That would be great !

keytrap-x86 avatar Apr 21 '20 15:04 keytrap-x86

Okay.. but how do I test? Is there a client that sends gzip content? What is your use case?

mevdschee avatar Apr 21 '20 20:04 mevdschee