func transferResponse(session *encoding.ServerSession, request *protocol.RequestHeader, response *protocol.ResponseHeader, input ray.InputStream, output io.Writer) error { session.EncodeResponseHeader(response, output) bodyWriter := session.EncodeResponseBody(request, output) // Optimize for small response packet data, err := input.Read() if err != nil { return err } if err := bodyWriter.Write(data); err != nil { return err } data.Release() if bufferedWriter, ok := output.(*bufio.BufferedWriter); ok { if err := bufferedWriter.SetBuffered(false); err != nil { return err } } if err := buf.PipeUntilEOF(input, bodyWriter); err != nil { return err } if request.Option.Has(protocol.RequestOptionChunkStream) { if err := bodyWriter.Write(buf.NewLocal(8)); err != nil { return err } } return nil }
func transferRequest(session *encoding.ServerSession, request *protocol.RequestHeader, input io.Reader, output ray.OutputStream) error { defer output.Close() bodyReader := session.DecodeRequestBody(request, input) if err := buf.PipeUntilEOF(bodyReader, output); err != nil { return err } return nil }