[internal.http.request] -> [internal.http.upgrade.request]

[http.upgrade.request] minmod
This commit is contained in:
xdrm-brackets 2018-04-25 15:54:15 +02:00
parent 45a3166dcc
commit ca472fb80c
8 changed files with 18 additions and 18 deletions

View File

@ -2,7 +2,7 @@ package request
import ( import (
"fmt" "fmt"
"git.xdrm.io/gws/internal/http/request/parser/header" "git.xdrm.io/gws/internal/http/upgrade/request/parser/header"
) )

View File

@ -6,11 +6,12 @@ import (
"io" "io"
) )
// Parse parses a byte array build a request object // Parse builds an upgrade HTTP request
func Parse(r io.Reader) (request *T, err error) { // from a reader (typically bufio.NewRead of the socket)
func Build(r io.Reader) (request *T, err error) {
/* (1) Get chunk reader */ /* (1) Get chunk reader */
cr, err := reader.NewReader(r) cr := reader.NewReader(r)
if err != nil { if err != nil {
return nil, fmt.Errorf("Error while creating chunk reader: %s", err) return nil, fmt.Errorf("Error while creating chunk reader: %s", err)
} }
@ -40,8 +41,6 @@ func Parse(r io.Reader) (request *T, err error) {
} }
/* (2) GET {uri} HTTP/{version} /* (2) GET {uri} HTTP/{version}
---------------------------------------------------------*/ ---------------------------------------------------------*/
/* (1) Break apart */ /* (1) Break apart */

View File

@ -1,20 +1,21 @@
package request package request
import "git.xdrm.io/gws/internal/http/request/parser/reqline" import "git.xdrm.io/gws/internal/http/upgrade/request/parser/reqline"
// T represents an HTTP Upgrade request // T represents an HTTP Upgrade request
type T struct { type T struct {
request reqline.T
host string
port uint16
origin string
key []byte
protocols []string
version int
first bool // whether the first line has been read (GET uri HTTP/version) first bool // whether the first line has been read (GET uri HTTP/version)
Err error // request line
request reqline.T
// http data
host string
port uint16 // 0 if not set
origin string
// ws data
key []byte
protocols []string
version byte
} }