code: func (s *Stream) sendWindowUpdate() error {
  	s.controlHdrLock.Lock()
  	defer s.controlHdrLock.Unlock()
  
  	// Determine the delta update
  	max := s.session.config.MaxStreamWindowSize
  	var bufLen uint32
  	s.recvLock.Lock()
  	if s.recvBuf != nil {
  		bufLen = uint32(s.recvBuf.Len())
  	}
  	delta := (max - bufLen) - s.recvWindow
  
  	// Determine the flags if any
  	flags := s.sendFlags()
  
  	// Check if we can omit the update
  	if delta < (max/2) && flags == 0 {
  		s.recvLock.Unlock()
  		return nil
  	}
  
  	// Update our window
  	s.recvWindow += delta
  	s.recvLock.Unlock()
  
  	// Send the header
  	s.controlHdr.encode(typeWindowUpdate, flags, s.id, delta)
  	if err := s.session.waitForSendErr(s.controlHdr, nil, s.controlErr); err != nil {
  		return err
  	}
  	return nil
  }
docs: // sendWindowUpdate potentially sends a window update enabling
  // further writes to take place. Must be invoked with the lock.