feat: remove stream related methods in req
This commit is contained in:
@ -6,8 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Request struct {
|
type Request struct {
|
||||||
@ -44,15 +42,6 @@ func (req *Request) GetDataFormat() (*DataFormat, error) {
|
|||||||
return ParseDataFormat(format)
|
return ParseDataFormat(format)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *Request) GetRequestKind() string {
|
|
||||||
_, ok := req.GetHeader(H_XSTREAM)
|
|
||||||
if ok {
|
|
||||||
return "stream"
|
|
||||||
}
|
|
||||||
|
|
||||||
return "single-hit"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (req *Request) GetRoute() string {
|
func (req *Request) GetRoute() string {
|
||||||
route, ok := req.GetHeader(H_ROUTE)
|
route, ok := req.GetHeader(H_ROUTE)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -62,36 +51,6 @@ func (req *Request) GetRoute() string {
|
|||||||
return route
|
return route
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *Request) GetStreamInfo() (*StreamInfo, error) {
|
|
||||||
stream, ok := req.GetHeader(H_XSTREAM)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("No X-STREAM header presented in request")
|
|
||||||
}
|
|
||||||
|
|
||||||
parts := strings.Split(stream, ":")
|
|
||||||
if len(parts) != 2 {
|
|
||||||
return nil, fmt.Errorf("Invalid value of X-STREAM header: '%s'", stream)
|
|
||||||
}
|
|
||||||
|
|
||||||
totalS, bufsizeS := parts[0], parts[1]
|
|
||||||
|
|
||||||
total, err := strconv.ParseUint(totalS, 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
bufsize, err := strconv.ParseUint(bufsizeS, 10, 16)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
buf := uint16(bufsize)
|
|
||||||
|
|
||||||
return &StreamInfo{
|
|
||||||
TotalBytes: total,
|
|
||||||
BufferSize: buf,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (req *Request) ExtractText() (string, error) {
|
func (req *Request) ExtractText() (string, error) {
|
||||||
df, err := req.GetDataFormat()
|
df, err := req.GetDataFormat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user