Skip to content
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

Need to process the body and status code of the response with an error #168

Open
fpawel opened this issue Jul 20, 2023 · 0 comments
Open

Comments

@fpawel
Copy link

fpawel commented Jul 20, 2023

Now in the case of a non-200 response code, calling the Client.Subscribe method returns an error without any information about the response

func (c *Client) SubscribeWithContext(ctx context.Context, stream string, handler func(msg *Event)) error {
	operation := func() error {
		...
		} else if resp.StatusCode != 200 {
			resp.Body.Close()
			return fmt.Errorf("could not connect to stream: %s", http.StatusText(resp.StatusCode))
		...

F.e. on 203 - could not connect to stream: Non-Authoritative Information
This is not appropriate in cases where the response code and body may provide additional context for client-side processing. For example, the server may respond with 203 + the result of the stream to a GET /events request .
I suppose it's easy to fix.
If I prepare a PR, can I expect it to be approved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant