diff --git a/http/upgrade/request/private.go b/http/upgrade/request/private.go index c9d56f7..52183eb 100644 --- a/http/upgrade/request/private.go +++ b/http/upgrade/request/private.go @@ -2,7 +2,7 @@ package request import ( "fmt" - "git.xdrm.io/gws/internal/http/request/parser/header" + "git.xdrm.io/gws/internal/http/upgrade/request/parser/header" ) diff --git a/http/upgrade/request/public.go b/http/upgrade/request/public.go index ec940d9..9144a2d 100644 --- a/http/upgrade/request/public.go +++ b/http/upgrade/request/public.go @@ -6,11 +6,12 @@ import ( "io" ) -// Parse parses a byte array build a request object -func Parse(r io.Reader) (request *T, err error) { +// Parse builds an upgrade HTTP request +// from a reader (typically bufio.NewRead of the socket) +func Build(r io.Reader) (request *T, err error) { /* (1) Get chunk reader */ - cr, err := reader.NewReader(r) + cr := reader.NewReader(r) if err != nil { 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} ---------------------------------------------------------*/ /* (1) Break apart */ diff --git a/http/upgrade/request/types.go b/http/upgrade/request/types.go index 91a79b8..783e7e4 100644 --- a/http/upgrade/request/types.go +++ b/http/upgrade/request/types.go @@ -1,20 +1,21 @@ 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 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) - 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 } diff --git a/internal/http/request/parser/header/public.go b/internal/http/upgrade/request/parser/header/public.go similarity index 100% rename from internal/http/request/parser/header/public.go rename to internal/http/upgrade/request/parser/header/public.go diff --git a/internal/http/request/parser/header/types.go b/internal/http/upgrade/request/parser/header/types.go similarity index 100% rename from internal/http/request/parser/header/types.go rename to internal/http/upgrade/request/parser/header/types.go diff --git a/internal/http/request/parser/reqline/private.go b/internal/http/upgrade/request/parser/reqline/private.go similarity index 100% rename from internal/http/request/parser/reqline/private.go rename to internal/http/upgrade/request/parser/reqline/private.go diff --git a/internal/http/request/parser/reqline/public.go b/internal/http/upgrade/request/parser/reqline/public.go similarity index 100% rename from internal/http/request/parser/reqline/public.go rename to internal/http/upgrade/request/parser/reqline/public.go diff --git a/internal/http/request/parser/reqline/types.go b/internal/http/upgrade/request/parser/reqline/types.go similarity index 100% rename from internal/http/request/parser/reqline/types.go rename to internal/http/upgrade/request/parser/reqline/types.go