Closed fgodskesen closed 2 years ago
It sounds cool. I am not very familiar with this feature. Is this something you are interested in providing a proof of concept?
I will make a PR on this shortly. I have hacked together a solution that at least partially works. It compresses the Response if gzip is present in the Accept-Encoding header. I have not done anything about request though.
Thanks for the PR! The package RestPS 7.0.36 was recently published on PowerShell Gallery by jpsider. Let me know how testing goes.
It looks like the current version 7.0.36 has a new bug. If you do NOT use the encoding header, the server crashes with a null pointer reading... 7.0.34 is working.
Can you paste the error? I'll try to reproduce and generate a fix.
Hi,
if I run:
Invoke-RestMethod -uri 'http://127.0.0.1:7777/rest/startsync' -Authentication bearer -Token $token -AllowUnencryptedAuthentication
I have the following error: 2021-02-15 14:58:20 TRACE: Start-RestPSListener: Streaming response back to requestor. InvalidOperation: C:\Users\cbeck\Documents\PowerShell\Modules\restps\7.0.36\RestPS.psm1:306:9 Line | 306 | if ($context.Request.Headers.Item('Accept-Encoding').Split(",").T … |
---|
| You cannot call a method on a null-valued expression.
Interstingly, if I run
Invoke-Webrequest -uri 'http://127.0.0.1:7777/rest/startsync'
-Authentication bearer -Token $token -AllowUnencryptedAuthentication
there is no error.
Best regards
Christian Beck
------ Originalnachricht ------
Von: "Justin Sider" <notifications@github.com>
An: "jpsider/RestPS" <RestPS@noreply.github.com>
Cc: "Christian Beck" <chb@chbworld.net>; "Comment"
<comment@noreply.github.com>
Gesendet: 13.02.2021 03:27:49
Betreff: Re: [jpsider/RestPS] add support for Accept-Encoding /
TransferEncoding gzip / deflate (#53)
>
>Can you paste the error? I'll try to reproduce and generate a fix.
>
>—
>You are receiving this because you commented.
>Reply to this email directly, view it on GitHub
><https://github.com/jpsider/RestPS/issues/53#issuecomment-778548051>,
>or unsubscribe
><https://github.com/notifications/unsubscribe-auth/ABV22JYYPTG4GEW7UOXPZE3S6XPSLANCNFSM4R6YGYSQ>.
>
Looks like I need to check if this variable is null and just move past it, instead of checking for something specific..
$context.Request.Headers.Item
in the Invoke-StreamOutput function
Before you check for something specific, you need to check if it is $null. That's a speciality of powershell. Therefore e.g. $myvar -eq '' might be wrong. You need to check for [string]::IsNullOrEmpty()
Hope you can fix this!
CU
CHB
------ Originalnachricht ------ Von: "Justin Sider" @.> An: "jpsider/RestPS" @.> Cc: "Christian Beck" @.>; "Comment" @.> Gesendet: 05.04.2021 01:11:52 Betreff: Re: [jpsider/RestPS] add support for Accept-Encoding / TransferEncoding gzip / deflate (#53)
Looks like I need to check if this variable is null and just move past it, instead of checking for something specific..
$context.Request.Headers.Item
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jpsider/RestPS/issues/53#issuecomment-813113768, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABV22JZYRX5GP7I52RXVPJ3THDW3RANCNFSM4R6YGYSQ.
Deployed 7.0.38 to the PS gallery. Didn't quite work the way I expected, but it is no longer throwing the error.
In our environment, we are contemplating using RestPS as an easy to build web service to populate and provide large amounts of data for operational use. In some cases, bandwidth consumption is a concern as parts of our business is connected via satellite connections.
As far as I can tell, the current implementation ignores any Accept-Encoding header sent by the consumer. I have only tested a GET method with Accept-Encoding, but I presume the same is the case for PUT / TransferEncoding.
Considering that json compresses very well, this could reduce the bandwidth usage by a good margin, increasing in efficiency with larger datasets.
/fgodskesen