Download internal/proxy/half_close.go from xjackkx/rg: direct link, hf CLI and curl.
- Browser
- Download file 562 Bytes
-
https://huggingface.co/spaces/xjackkx/rg/resolve/main/internal/proxy/half_close.go
- Command line
-
hf download hf://spaces/xjackkx/rg/internal/proxy/half_close.go
-
curl -L -o half_close.go https://huggingface.co/spaces/xjackkx/rg/resolve/main/internal/proxy/half_close.go
562 Bytes
| package proxy | |
| import ( | |
| "errors" | |
| "net" | |
| ) | |
| var errHalfCloseUnsupported = errors.New("half-close unsupported") | |
| func closeWriteErr(conn net.Conn) error { | |
| if conn == nil { | |
| return net.ErrClosed | |
| } | |
| closeWriter, ok := conn.(interface{ CloseWrite() error }) | |
| if !ok { | |
| return errHalfCloseUnsupported | |
| } | |
| return closeWriter.CloseWrite() | |
| } | |
| func closeReadErr(conn net.Conn) error { | |
| if conn == nil { | |
| return net.ErrClosed | |
| } | |
| closeReader, ok := conn.(interface{ CloseRead() error }) | |
| if !ok { | |
| return errHalfCloseUnsupported | |
| } | |
| return closeReader.CloseRead() | |
| } | |