Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Support supplying headers in ResponseProvider #13

Open
bowenwr opened this issue Apr 17, 2017 · 2 comments
Open

Support supplying headers in ResponseProvider #13

bowenwr opened this issue Apr 17, 2017 · 2 comments

Comments

@bowenwr
Copy link

bowenwr commented Apr 17, 2017

I have a Tyrus based Java websocket client. When attempting to make a connection like:

server.expect().get().withPath("/websocket").andUpgradeToWebSocket().open())

The client throws a handshake exception:

INFO: MockWebServer[57060] received request: GET /websocket HTTP/1.1 and responded: HTTP/1.1 404 Client Error
Apr 17, 2017 5:15:52 PM okhttp3.mockwebserver.MockWebServer$2 acceptConnections
INFO: MockWebServer[57060] done accepting connections: Socket closed

javax.websocket.DeploymentException: Handshake error.

When I attempt to mock out the HTTP side with a 101 response like:

server.expect().withPath("/websocket").andReturn(101, "").always();

It bombs because of a null upgrade header:

Caused by: org.glassfish.tyrus.core.HandshakeException: Invalid Upgrade header value: "null".

I couldn't find any way in ResponseProvider to set headers, only status and body content.

Thanks for a great project!

@iocanel
Copy link
Member

iocanel commented Dec 27, 2017

Hmmm, the header should already be set.

@iocanel
Copy link
Member

iocanel commented Dec 27, 2017

Yeah, this is handled by okhttp itself. Anyway, I'll add something on top of that just to make sure. Also, it will allow setting custom headers.

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

No branches or pull requests

2 participants