Open bowenwr opened 7 years ago
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.
ResponseProvider
Thanks for a great project!
Hmmm, the header should already be set.
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.
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:
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!