If you get HTTP 417 (Expectation) for PUTs....
Opened this issue · 0 comments
I'm writing home automation code in .NET that will run on both Linux and Windows systems. It is the same binary file on both. Once past the usual fun of ignoring the certificate errors you get trying to do a PUT to the television, I started getting HTTP 417 responses on the Linux (RPi) tests for PUT operations (like sending a Power keypress) telling me it couldn't support the HTTP Expect header I was sending and fail the call. On Windows I originally saw these errors but by setting the HttpWebRequest.Expect to null, all was good. This solution did NOT work on Linux, however, under Mono. After much trial and error I found that the way to tell both Linux and Windows not to expect the 100-Continue behavior for the TV was by setting the following property to false along with the other request parameters before calling GetResponse():
{Instance of HttpWebRequest}.ServicePoint.Expect100Continue = false;
Once this is set, the PUTs work perfectly on both OS platforms.
Maybe obvious to the net gods out there but thought I'd share my experience with everyone as I can't stand chasing odd bugs like this.
This might be a good thing to add to the docs on the main page.