dreamhost-dynamic-dns
dreamhost-dynamic-dns copied to clipboard
E_NOTICE caused by missing content type.
The POST request to the Dreamhost API is sent without a content type (application/x-www-form-urlencoded
) which PHP will fill in, but also throw an E_NOTICE about.
Unfortunately, if E_NOTICE warnings are enabled, the custom error handler will pick up that (by itself non-fatal) warning and turn it into a fatal error by calling exit()
.
The best solution seems to be explicitly specifying the content type.
I added it in DreamDynDns\Api\ApiModule::request()
, but maybe there's a better place. (Also, adjust for your preferred code-style of course.)
--- a/DreamDynDns/Api/ApiModule.php
+++ b/DreamDynDns/Api/ApiModule.php
@@ -67,8 +67,8 @@ abstract class ApiModule
'unique_id' => uniqid($this->uniquePrefix, true)
),
$params
- )
+ ), $this->requestMethod == 'POST' ? ['Content-type' => 'application/x-www-form-urlencoded'] : NULL
));
}
-}
\ No newline at end of file
+}
With this change I got it to successfully set a record.
Thanks! :)