func (s *Stream) Write(b []byte) (int, error) {
	if s.send.closed {
		return 0, io.EOF
	}
	if s.send.stopReceived {
		s.send.setClosed()  
		return 0, newAppError(s.send.resetError, "stop_sending")
	}
	if s.send.buf.size() > maxStreamBuffer {
		return 0, nil
	}
	n := int(s.flow.availSend())
	if n <= 0 {
		return 0, nil
	}
	if n < len(b) {
		b = b[:n]
	}
	n, err := s.send.Write(b)
	if n > 0 {
		s.flow.setSend(s.send.length)
		if s.isSendBlocked() {
			s.flow.setSendBlocked(true)
		}
	}
	return n, err
}
Write writes data to send stream.
Writing to a read-only or closed stream will result in error io.EOF.
package transport
import (
	"fmt"
	"io"
)
const (
	maxStreams = 1 << 60
	minStreamBufferWritable = 8 << 10
	maxStreamBuffer         = 128 << 10
)
type deliveryState uint8
const (
	deliveryNone deliveryState = iota
	deliveryReady
	deliverySending
	deliveryConfirmed
)
type Stream struct {
	recv recvStream
	send sendStream
	flow flowControl
	connFlow *flowControl
	updateMaxData bool
	local bool
	bidi  bool
}
func (s *Stream) init(local, bidi bool) {
	s.local = local
	s.bidi = bidi
	if !bidi {
		if local {
			s.recv.setClosed()  
		} else {
			s.send.setClosed()  
		}
	}
}
func (s *Stream) pushRecv(data []byte, offset uint64, fin bool) error {
	if offset+uint64(len(data)) > s.flow.recvMax {
		return newError(FlowControlError, sprint("stream: data exceeded limit ", s.flow.recvMax))
	}
	err := s.recv.push(data, offset, fin)
	if err == nil {
		s.flow.setRecv(s.recv.length)
	}
	return err
}
func (s *Stream) Read(b []byte) (int, error) {
	if s.recv.closed {
		return 0, io.EOF
	}
	n, err := s.recv.Read(b)
	if n > 0 {
		s.consumeRecv(uint64(n))
	}
	return n, err
}