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
Added more clear specification. #944
Conversation
proposed/http-client/http-client.md
Outdated
response. When there is an error during sending the request or an error with network an | ||
exception should be thrown. | ||
response. The HTTP client MAY modify the response from the server before returning | ||
the PSR-7 response. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this (minus typo ^^) would be better IMO:
"The HTTP client MAY modify the request, given by the user and sent to the server or the response from the server before returning. In this case the request and the response must be consistent between the body and headers. I.e. a server may return a gzip encoded body and the client may know how to decode this, when it decodes the body the client MUST also remove the header that specify this encoding."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is what we mean by this, then yes lets give this example to illustrate what we actually mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!
proposed/http-client/http-client.md
Outdated
response. When there is an error during sending the request or an error with network an | ||
exception should be thrown. | ||
response. The HTTP client MAY modify the response from the server before returning | ||
the PSR-7 response. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this is what we mean by this, then yes lets give this example to illustrate what we actually mean.
proposed/http-client/http-client.md
Outdated
the server or the response from the server before returning. In this case the | ||
request and the response must be consistent between the body and headers. I.e. a | ||
server may return a gzip encoded body and the client may know how to decode this, | ||
when it decodes the body the client MUST also remove the header that specify this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this line mixes singular and plural. either "remove the headers that specify" or "remove the header that specifies". i think the second makes more sense, the encoding example would have just one header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!
proposed/http-client/http-client.md
Outdated
@@ -12,8 +12,12 @@ interpreted as described in [RFC 2119](http://tools.ietf.org/html/rfc2119). | |||
### Client | |||
|
|||
An HTTP client has the responsibility to send a PSR-7 request and return a PSR-7 | |||
response. The HTTP client MAY modify the response from the server before returning | |||
the PSR-7 response. | |||
response. The HTTP client MAY modify the request, given by the user and sent to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Under the hood the HTTP client MAY modify the request/response received from the user/server."
How does that sound?
This part tries to make it clear that under the contract surface anything could happen to request/response objects and there is no assurance that they will remain the same objects on the instance level, right?
proposed/http-client/http-client.md
Outdated
the PSR-7 response. | ||
response. The HTTP client MAY modify the request, given by the user and sent to | ||
the server or the response from the server before returning. In this case the | ||
request and the response must be consistent between the body and headers. I.e. a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I.e. -> "For example," ?
proposed/http-client/http-client.md
Outdated
the server or the response from the server before returning. In this case the | ||
request and the response must be consistent between the body and headers. I.e. a | ||
server may return a gzip encoded body and the client may know how to decode this, | ||
when it decodes the body the client MUST also remove the header that specify this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specify the encoding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, chose the wrong option, see my outdated comments above.
proposed/http-client/http-client.md
Outdated
`Psr\Http\Client\Exception\RequestException`. | ||
|
||
When there is an error with the network or the remote server cannot be reached, the | ||
HTTP client SHOULD thrown a `Psr\Http\Client\Exception\NetworkException`. If the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thrown
-> throw
Generally as a rule, SHOULD
is recommended against as it cannot be relied upon by a client anymore. Is there rationale as to why this isn't a MUST
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in some circumstances it might be difficult to know what kind of error happened. there will probably always be some fuzzyness around the exception type. however, we are specific as to which things cause a network exception, so i think MUST should be fine here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you fix the thrown throw please?
ok if we say MUST here?
proposed/http-client/http-client.md
Outdated
exception should be thrown. | ||
response. The HTTP client MAY modify the request, given by the user and sent to | ||
the server or the response from the server before returning. In this case the | ||
request and the response must be consistent between the body and headers. I.e. a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I.e.
doesn't make much sense in this context. Perhaps use For example
instead.
proposed/http-client/http-client.md
Outdated
the server or the response from the server before returning. In this case the | ||
request and the response must be consistent between the body and headers. I.e. a | ||
server may return a gzip encoded body and the client may know how to decode this, | ||
when it decodes the body the client MUST also remove the header that specifies this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using a MUST
inside an example doesn't make much sense. Suggestion:
and the client may know how to decode this, however the client should then also mutate the headers that specify the encoding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, the MUST is important here. should we move that out of the example to say that if the client modifies the request or response, it MUST also adjust the headers accordingly? (i'd assume that if it gzips a request, it must also adjust the content-length header, for example)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
proposed/http-client/http-client.md
Outdated
server may return a gzip encoded body and the client may know how to decode this, | ||
when it decodes the body the client MUST also remove the header that specifies this | ||
when it decodes the body the client MUST also remove the header that specifies the | ||
encoding. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and update the content length header. (cf @dbu comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we add the section about when to throw exceptions, should we also say here to not throw exceptions for any http status?
proposed/http-client/http-client.md
Outdated
`Psr\Http\Client\Exception\RequestException`. | ||
|
||
When there is an error with the network or the remote server cannot be reached, the | ||
HTTP client MUST thrown a `Psr\Http\Client\Exception\NetworkException`. If the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/thrown/throw
proposed/http-client/http-client.md
Outdated
When there is an error with the network or the remote server cannot be reached, the | ||
HTTP client MUST thrown a `Psr\Http\Client\Exception\NetworkException`. If the | ||
request is invalid and cannot be sent the HTTP client MUST throw a | ||
`Psr\Http\Client\Exception\RequestException`. Smaller issues like wrong HTTP version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would swap the 2 points, so they are more in order of when they happen (invalid request is detected first, network problem only later)
proposed/http-client/http-client.md
Outdated
It SHOULD implement exceptions for `Psr\Http\Client\Exception\NetworkException` and | ||
`Psr\Http\Client\Exception\RequestException`. | ||
|
||
When there is an error with the network or the remote server cannot be reached, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about an invalid response, should we mention that here? like not proper http or such.
Thank you @dbu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the updates. now i only have nitpick comments left ;-)
proposed/http-client/http-client.md
Outdated
It SHOULD implement exceptions for `Psr\Http\Client\Exception\NetworkException` and | ||
`Psr\Http\Client\Exception\RequestException`. | ||
|
||
When the client get a request that is invalid and cannot be sent, the HTTP client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the HTTP client is passed a request that ... sent , the client
proposed/http-client/http-client.md
Outdated
Smaller issues like wrong HTTP version is not blocking the HTTP client to send the | ||
request and MUST not cause any exception. | ||
|
||
No exception should be thrown if the remote server answers with an response that can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the remote server answers with a response that can be parsed into a PSR-7 response, the client MUST NOT throw an exception. For example, response status codes in the 400 and 500 range MUST NOT cause an exception.
Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you. i am happy now.
@michaelcullum @sagikazarmark what do you think of this now? (as your status on this is "request changes")
I've addressed their issues. Im merging this to move forward. Feel free to open issues or PRs to make additional changes. |
Im trying to address @joelwurtz comment and part of php-http#34