php-hal-client icon indicating copy to clipboard operation
php-hal-client copied to clipboard

Made the mime type configureable.

Open florianwagner81 opened this issue 9 years ago • 4 comments

I think it might be very helpful for others as well to make the default content mime type configurable as it was causing issues for pure "application/json" API i.e.

florianwagner81 avatar Aug 10 '16 15:08 florianwagner81

This cannot be done with a static variable as we can consume 2 differents API within the same request lifetime.

rande avatar Aug 11 '16 15:08 rande

What do you suggest?

What is needed:

  • Set the Content Type before each query
  • (Optional) Reset to default after query

Possible solution:

  • Set Content Type like in my fork?! (see example below)
  • Adding a new parameter whith default value to the parse function (That would mean several other changes to pass the parameter through.)
  • Change EntryPoint construtor to accept contentType

Atm I run my queries like this:

// get resource from remote
$entryPoint = new EntryPoint($query, $client);
$entryPoint::setDefaultContentType("application/json");
$resource = $entryPoint->get();

florianwagner81 avatar Aug 12 '16 07:08 florianwagner81

Possibly disable the check content-type is better ?

EntryPoint::$contentType = false;

pokap avatar Aug 12 '16 08:08 pokap

The best option will be to add a options parameters. And of course this will require to change different methods signature.

@pokap's solution can work too, but maybe with a different name: checkContentType

rande avatar Aug 16 '16 13:08 rande