MCPcopy Create free account
hub / github.com/gavv/httpexpect / Close

Method Close

websocket.go:250–271  ·  view source on GitHub ↗

Close cleanly closes the underlying WebSocket connection by sending an empty close message and then waiting (with timeout) for the server to close the connection. WebSocket close code may be optionally specified. If not, then "1000 - Normal Closure" will be used. WebSocket close codes are defined

(code ...int)

Source from the content-addressed store, hash-verified

248// conn := resp.Connection()
249// conn.Close(websocket.CloseUnsupportedData)
250func (ws *Websocket) Close(code ...int) *Websocket {
251 opChain := ws.chain.enter("Close()")
252 defer opChain.leave()
253
254 switch {
255 case ws.checkUnusable(opChain, "Close()"):
256 return ws
257
258 case len(code) > 1:
259 opChain.fail(AssertionFailure{
260 Type: AssertUsage,
261 Errors: []error{
262 errors.New("unexpected multiple code arguments"),
263 },
264 })
265 return ws
266 }
267
268 ws.writeMessage(opChain, websocket.CloseMessage, nil, code...)
269
270 return ws
271}
272
273// CloseWithBytes cleanly closes the underlying WebSocket connection
274// by sending given slice of bytes as a close message and then waiting

Callers

nothing calls this directly

Calls 5

checkUnusableMethod · 0.95
writeMessageMethod · 0.95
enterMethod · 0.80
leaveMethod · 0.80
failMethod · 0.80

Tested by

no test coverage detected