dotcloud/docker — pull request #1146 by benoitc (2013-07-05 23:40:47+00:00)
Title: add websocket support to /container/<name>/attach/ws

This function add the possibility to attach containers streams to a
websocket. When a websocket is asked the request is upgraded to this
protocol..

Example of usage:

package main

import (
"fmt"
"code.google.com/p/go.net/websocket"
)

func main() {
origin := "http://localhost/"
url :=
"ws://localhost:4243/v1.3/containers/450a8d4a34ee/attach/ws?logs=1&stderr=1&stdout=1"
ws, err := websocket.Dial(url, "", origin)
if err != nil {
fmt.Printf("error: %s", err)
return
}

for {
msg := make([]byte, 500)
var n int
if n, err = ws.Read(msg); err != nil {
break
}
fmt.Printf("%s.\n", msg[:n])
}
}