Skip to content

Allow to specify a status for streaming endpoints#966

Merged
phadej merged 1 commit intohaskell-servant:masterfrom
jvanbruegge:stream-code
Jun 9, 2018
Merged

Allow to specify a status for streaming endpoints#966
phadej merged 1 commit intohaskell-servant:masterfrom
jvanbruegge:stream-code

Conversation

@jvanbruegge
Copy link
Copy Markdown
Contributor

@jvanbruegge jvanbruegge commented May 27, 2018

Currently streaming endpoints are always returning 200 OK. With this it is not possible to implement e.g. Range Requests, as those need to return 206 Partial Content. This PR changes this.

@alpmestan
Copy link
Copy Markdown
Contributor

Your other PR has been merged, so you can rebase this one now :)

@jvanbruegge jvanbruegge changed the title WIP: Allow to specify a status for streaming endpoints Allow to specify a status for streaming endpoints May 28, 2018
@jvanbruegge
Copy link
Copy Markdown
Contributor Author

Rebased

@alpmestan
Copy link
Copy Markdown
Contributor

Modulo updating docs/tutorial/etc, this looks to me. @phadej @gbaz Any objection?

@phadej
Copy link
Copy Markdown
Contributor

phadej commented May 28, 2018

Test(s) would be great as well.

@jvanbruegge
Copy link
Copy Markdown
Contributor Author

How would I write a test for this? I guess I somehow have to assert the status code, but I am not sure how to get that status with clientM. I am only using servant-server myself

@gbaz
Copy link
Copy Markdown
Contributor

gbaz commented May 28, 2018

Hmm... the stream tests are in StreamSpec: https://github.com/gbaz/servant/blob/db13077ccb93223e606ace6f7a67ac9389375a6a/servant-client/test/Servant/StreamSpec.hs

You can probably test for status codes as in: https://github.com/gbaz/servant/blob/db13077ccb93223e606ace6f7a67ac9389375a6a/servant-client/test/Servant/ClientSpec.hs#L338

@jvanbruegge
Copy link
Copy Markdown
Contributor Author

responseStatusCode, thats what I searched for. I only looked at the StreamSpec tests, my fault

@jvanbruegge
Copy link
Copy Markdown
Contributor Author

Currently streaming endpoints only return a ResultStream, there is no way to get the status code. Should I add a Status entry on the ResultStream type, in addition to the IO Continuation?
I'm not sure how you would want to handle this. I haven't had (and will not for at least this week) have time to look deeper into the servant-client code base to take a look how normal responses handle this.

@jvanbruegge
Copy link
Copy Markdown
Contributor Author

I can confirm that this works. I was able to implement HTTP range requests with Servant and Conduit: jvanbruegge/media-goggler@b77da5e

@phadej phadej merged commit f53370b into haskell-servant:master Jun 9, 2018
@jvanbruegge jvanbruegge deleted the stream-code branch June 9, 2018 09:28
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

Successfully merging this pull request may close these issues.

4 participants