diff --git a/httpRequest.proto b/httpRequest.proto index 5b3d2c7..e2ad1a7 100644 --- a/httpRequest.proto +++ b/httpRequest.proto @@ -4,25 +4,30 @@ syntax = "proto3"; package httppb; +// todo: try this +// import "google/rpc/status.proto"; +// google.rpc.Status error = 13; import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp -message HttpRequest { // HttpRequest represents the essential fields of an incoming HTTP request. - string method = 1; // The request method, e.g., "GET", "POST". - string URL = 2; // The full URL of the request, including scheme, host, path, and query string. - string route = 3; // just the route: "/add/" or "/find/" - string proto = 4; // The protocol version, e.g., "HTTP/1.1", "HTTP/2.0". - map headers = 5; // The map of request headers. Header names are case-insensitive, - string IP = 6; // The remote IP address of the client, after resolving proxies. - string host = 7; // The host on which the URL is sought (www.wit.com) - string hostname = 8; // The hostname of the client if passed from the client (mylaptop.fun.me) - bytes body = 9; // The request body as raw bytes. - string namespace = 10; // When the body is a pb (always!). This is the pb namespace ("go.wit.com/lib/protobuf/virtpb") - google.protobuf.Timestamp ctime = 11; // create time of the patch - repeated string errors = 12; // When the body is a pb (always!). This is the pb namespace ("go.wit.com/lib/protobuf/virtpb") +message HttpRequest { // HttpRequest represents the essential fields of an incoming HTTP request. + string method = 1; // The request method, e.g., "GET", "POST". + string URL = 2; // The full URL of the request, including scheme, host, path, and query string. + string route = 3; // just the route: "/add/" or "/find/" + string proto = 4; // The protocol version, e.g., "HTTP/1.1", "HTTP/2.0". + map headers = 5; // The map of request headers. Header names are case-insensitive, + string IP = 6; // The remote IP address of the client, after resolving proxies. + string host = 7; // The host on which the URL is sought (www.wit.com) + string hostname = 8; // The hostname of the client if passed from the client (mylaptop.fun.me) + string namespace = 9; // This is the pb namespace ("go.wit.com/lib/protobuf/virtpb") + google.protobuf.Timestamp ctime = 10; // create time of the patch + bytes clientData = 11; // the client payload + int64 clientDataLen = 12; // len(body) + bytes serverData = 13; // the server response + int64 serverDataLen = 14; // len(data) } -message HttpRequests { // `autogenpb:marshal` `autogenpb:mutex` - string uuid = 1; // `autogenpb:uuid:1524ed43-e57d-4bf9-9449-1cdfdc498605` - string version = 2; // `autogenpb:version:v0.0.1` - repeated HttpRequest HttpRequests = 3; // THIS MUST BE HttpRequest and then HttpRequests +message HttpRequests { // `autogenpb:marshal` `autogenpb:mutex` + string uuid = 1; // `autogenpb:uuid:1524ed43-e57d-4bf9-9449-1cdfdc498605` + string version = 2; // `autogenpb:version:v0.0.1` + repeated HttpRequest HttpRequests = 3; // THIS MUST BE HttpRequest and then HttpRequests } diff --git a/post.go b/post.go index 8ced07f..f18de27 100644 --- a/post.go +++ b/post.go @@ -54,7 +54,10 @@ func DoPost(baseURL string, route string, data []byte) (*HttpRequest, error) { reqPB, err := ReqToPB(req) reqPB.URL = finalURL.String() - reqPB.Body = body + reqPB.ClientData = data + reqPB.ClientDataLen = int64(len(data)) + reqPB.ServerData = body + reqPB.ServerDataLen = int64(len(body)) return reqPB, nil } diff --git a/reqToPB.go b/reqToPB.go index f5aa766..019ad77 100644 --- a/reqToPB.go +++ b/reqToPB.go @@ -58,14 +58,15 @@ func ReqToPB(r *http.Request) (*HttpRequest, error) { // log.Info("TRYING TO MARSHAL bytes:", len(msg), err) pb := &HttpRequest{ - Method: r.Method, - URL: r.URL.String(), - Proto: r.Proto, - Headers: headers, - IP: getClientIP(r), - Host: r.Host, - Body: msg, - Hostname: r.Header.Get("hostname"), + Method: r.Method, + URL: r.URL.String(), + Proto: r.Proto, + Headers: headers, + IP: getClientIP(r), + Host: r.Host, + ClientData: msg, + ClientDataLen: int64(len(msg)), + Hostname: r.Header.Get("hostname"), } pb.Route = cleanURL(r.URL.Path)