fast-cgi-client icon indicating copy to clipboard operation
fast-cgi-client copied to clipboard

ComposesRequestContent->toString() and immutable request content

Open sanderdlm opened this issue 1 year ago • 1 comments

Branch started from https://github.com/hollodotme/fast-cgi-client/pull/74.

2 API improvements with a BC break:

  • AbstractRequest->setContent is removed, making the content of a request immutable. Content can only be defined when creating the request, through the constructor. The script filename was already like this, and having both of them immutable results in a more resilient request object.
  • ComposesRequestContent->getContent renamed to toString, see:
    • The old method name was confusing in the context of a request already having content, which ended up looking like: $request->getContent()->getContent(); toString better illustrates what this method does, which is return a string representation of the request content.

sanderdlm avatar Mar 27 '23 19:03 sanderdlm

It doesn't really make sense to me to have a setter for contentType either now. With setContent gone and the content property requiring an implementation of the interface, if someone wants to send a specific type of content, he'll have to create his own class implementing ComposesRequestContent anyway, and by doing so he'll set the content-type in there.

What do you think?

sanderdlm avatar Mar 27 '23 19:03 sanderdlm