From ca472fb80c48b1b7222248f0b3520e93e6595a10 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 25 Apr 2018 15:54:15 +0200 Subject: [PATCH] [internal.http.request] -> [internal.http.upgrade.request] [http.upgrade.request] minmod --- http/upgrade/request/private.go | 2 +- http/upgrade/request/public.go | 9 +++---- http/upgrade/request/types.go | 25 ++++++++++--------- .../request/parser/header/public.go | 0 .../request/parser/header/types.go | 0 .../request/parser/reqline/private.go | 0 .../request/parser/reqline/public.go | 0 .../request/parser/reqline/types.go | 0 8 files changed, 18 insertions(+), 18 deletions(-) rename internal/http/{ => upgrade}/request/parser/header/public.go (100%) rename internal/http/{ => upgrade}/request/parser/header/types.go (100%) rename internal/http/{ => upgrade}/request/parser/reqline/private.go (100%) rename internal/http/{ => upgrade}/request/parser/reqline/public.go (100%) rename internal/http/{ => upgrade}/request/parser/reqline/types.go (100%) 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