-
Notifications
You must be signed in to change notification settings - Fork 22
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
Question: Content-length for Invoke-Restmethod #32
Comments
I'm trying to remember how this went as it was an issue I faced in a previous job so I don't have access to their issue tracker to refresh my own memory. As I recall, I was faced with an issue while making our test environment scriptable. I believe the problem was that when it was calling the service against my local instance of RabbitMQ, the call was failing because the content length was being sent through explicitly as -1, rather than calculating the size automatically. Setting the content length to 0, caused underlying HTTP library to calculate the length automatically. Attempting to read up on the issue, suggests to me that perhaps it might have been a compatibility issue with Fiddler (hence why it was only failing on localhost?) Given the dates of these commits, it's also quite possible that this was fixed/broken(?) in Powershell 5.0 or 5.1. I have a feeling that the commits were cherry picked from my fork of the repository as I can't find any Issue or PR related to these commits, which makes me think it was a problem I was having on my PC and not on my workmates. Hope that helps. |
Thanks for the context @AtomicBlom. My sense was that it may have been something that was fixed in later versions of PS. |
I was having a similar issue when running get-rabbitmqmessage. FWIW, I commented out the 'else' clause and it ran fine. |
I'm looking for some enlightenment here if someone is so inclined to help me.
In the proxy for Invoke-Restmethod there is the following code
which was introduced by @AtomicBlom in commit 897682c
The commit message ("Improve Invoke-RestMethod handling for talking to localhost") is confusing, as these changes don't seem to have anything to do with that.
I ended up here after debugging the following error when calling
I was able to get things working by removing the statement in the else clause. Does someone have an idea why the content length is set to zero? I've tried to find the origin of the comment "#By default the content-length is -1, which prevents ['Body'] from setting the content length." to determine the reason for this code.
Enquiring minds want to know.
Additional Details
Powershell version:
Major Minor Build Revision
5 1 14393 1944
Occurs on both: Windows Server 2016 (version 1709) & Windows 10 (version 1607)
The text was updated successfully, but these errors were encountered: