func (c *MessageStream) SendSSLRequestResponse(r byte) error {
	if c.state != ConnStartup {
		return fmt.Errorf("SendSSLRequestResponse called while the connection is not in the startup phase")
	}
	_, err := c.rw.Write([]byte{r})
	return err
}
Send a response to an SSLRequest to the message stream.  See
RejectSSLRequest and AcceptSSLRequest.
package core
import (
	"bytes"
	"encoding/binary"
	"fmt"
	"github.com/uhoh-itsmaciek/femebe/buf"
	"github.com/uhoh-itsmaciek/femebe/util"
	"io"
)
type Stream interface {
	util.Flusher
	Send(m *Message) error
	HasNext() bool
	Next(m *Message) error
	Close() error
}
const MsgHeaderMinSize = 5
const startupMessageRequestCode uint32 = 196608
const RejectSSLRequest = 'N'
const AcceptSSLRequest = 'S'
type ConnState int32
const (
	ConnStartup ConnState = iota
	ConnNormal
	ConnErr
)
type MessageStream struct {
	rw    io.ReadWriteCloser
	state ConnState
	err   error
	msgRemainder bytes.Buffer
	scratchBuf [8192]byte
}
func baseNewMessageStream(rw io.ReadWriteCloser, state ConnState) *MessageStream {
	buf := bytes.NewBuffer(make([]byte, 0, 8192))
	return &MessageStream{
		rw:           rw,
		msgRemainder: *buf,
		state:        state,
	}
}
func NewFrontendStream(rw io.ReadWriteCloser) *MessageStream {
	return baseNewMessageStream(rw, ConnStartup)
}
func NewBackendStream(rw io.ReadWriteCloser) *MessageStream {
	return baseNewMessageStream(rw, ConnNormal)
}
func (c *MessageStream) HasNext() bool {
	return c.msgRemainder.Len() >= MsgHeaderMinSize
}
func (c *MessageStream) readStartupMessage(dst *Message) (err error) {
	msgSz, err := buf.ReadUint32(c.rw)
	if err != nil {
		return err
	}
	if msgSz < 8 {
		return fmt.Errorf("startup message size %d is invalid", msgSz)
	}
	requestCode := make([]byte, 4)
	_, err = c.rw.Read(requestCode)
	if err != nil {
		return err
	}
	dst.InitPromise(MsgTypeFirst, msgSz, requestCode, c.rw)
	if binary.BigEndian.Uint32(requestCode) == startupMessageRequestCode {
		c.state = ConnNormal
	}
	return nil
}