diff --git a/EXAMPLES.md b/EXAMPLES.md index fbb7734..868bccc 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -423,19 +423,19 @@ Total curl args: -s -X POST - --data-binary - @ --output --dump-header + --data-binary + @ -H Content-Type: application/x-protobuf http://localhost:8080/happy-day/verify =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Tue, 03 Oct 2023 09:29:50 GMT +Date: Tue, 03 Oct 2023 20:46:17 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 35 diff --git a/doc/generated.usage.txt b/doc/generated.usage.txt index 70fa906..080e1e9 100644 --- a/doc/generated.usage.txt +++ b/doc/generated.usage.txt @@ -22,13 +22,13 @@ Flags: --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -h, --help help for protocurl --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST (default) and GET supported. Other methods are passed on on to curl optimistically. (default "POST") + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on on to curl optimistically. (default "POST") --no-curl Forces the use of the built-in internal http request instead of curl. -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. @@ -37,7 +37,7 @@ Flags: --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Mandatory: Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. E.g. mypackage.MyRequest or ..MyRequest + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to diff --git a/src/flags.go b/src/flags.go index ffa59f1..3e1c5db 100644 --- a/src/flags.go +++ b/src/flags.go @@ -61,11 +61,10 @@ func intialiseFlags() { "Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred.") flags.StringVarP(&CurrentConfig.Method, "method", "X", "POST", - "HTTP request method. POST (default) and GET supported. Other methods are passed on on to curl optimistically.") + "HTTP request method. POST and GET are explicitly supported. Other methods are passed on on to curl optimistically.") flags.StringVarP(&CurrentConfig.RequestType, "request-type", "i", "", - "Mandatory: Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. E.g. mypackage.MyRequest or ..MyRequest") - AssertSuccess(rootCmd.MarkFlagRequired("request-type")) + "Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest") flags.StringVarP(&CurrentConfig.ResponseType, "response-type", "o", "", "The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used.") @@ -87,10 +86,10 @@ func intialiseFlags() { AssertSuccess(rootCmd.MarkFlagRequired("url")) flags.StringVarP(&CurrentConfig.DataText, "data-text", "d", "", - "Mandatory: The payload data in Protobuf text format or JSON. "+ + "The payload data in Protobuf text format or JSON. "+ "It is inferred from the input as JSON if the first token is a '{'. "+ - "The format can be set explicitly via --in. See "+GithubRepositoryLink) - AssertSuccess(rootCmd.MarkFlagRequired("data-text")) + "The format can be set explicitly via --in. Mandatory if request-type is provided."+ + "See "+GithubRepositoryLink) flags.BoolVarP(&CurrentConfig.NoDefaultHeaders, "no-default-headers", "n", false, "Default headers (e.g. \"Content-Type\") will not be passed to curl. Assumes --curl. Use \"-n -H 'Content-Type: FooBar'\" to override the default content type.") @@ -155,6 +154,16 @@ func propagateFlags() { fmt.Printf("Got method %s which is not explicitly supported. Proceeding optimistically.", CurrentConfig.Method) } + if CurrentConfig.Method == "POST" { + if CurrentConfig.RequestType == "" { + PanicWithMessage("With method POST, a request type and the data text is needed. However, request type was not provided. Aborting.") + } + } + + if CurrentConfig.DataText != "" && CurrentConfig.RequestType == "" { + PanicWithMessage("Non-empty data-body as provided, but no request type was given. Hence, encoding of data-body is not possible.") + } + if strings.HasPrefix(strings.TrimSpace(CurrentConfig.DataText), "{") { tmpDataTextInferredType = IJson } else { diff --git a/src/httpRequest.go b/src/httpRequest.go index 2bc803e..0538d96 100644 --- a/src/httpRequest.go +++ b/src/httpRequest.go @@ -28,7 +28,20 @@ func invokeInternalHttpRequest(requestBinary []byte) ([]byte, string) { PanicDueToUnsupportedHeadersWhenInternalHttp(CurrentConfig.RequestHeaders) } - httpResponse, err := http.Post(CurrentConfig.Url, DefaultContentType, bytes.NewReader(requestBinary)) + var httpResponse *http.Response + var err error + switch CurrentConfig.Method { + case "GET": + if CurrentConfig.RequestType != "" { + PanicWithMessage("Internal Http implementation doesn't support GET requests with body. Please use curl.") + } + httpResponse, err = http.Get(CurrentConfig.Url) + case "POST": + httpResponse, err = http.Post(CurrentConfig.Url, DefaultContentType, bytes.NewReader(requestBinary)) + default: + PanicWithMessage("HTTP method " + CurrentConfig.Method + " not supported with internal HTTP implementation. Please use curl.") + } + PanicWithMessageOnError(err, func() string { return "Failed internal HTTP request. Error: " + err.Error() }) defer func() { _ = httpResponse.Body.Close() }() @@ -68,10 +81,14 @@ func invokeCurlRequest(requestBinary []byte, curlPath string) ([]byte, string) { curlPath, "-s", "-X", CurrentConfig.Method, - "--data-binary", "@" + requestBinaryFile, "--output", responseBinaryFile, "--dump-header", responseHeadersTextFile, } + + if CurrentConfig.RequestType != "" { + curlArgs = append(curlArgs, "--data-binary", "@"+requestBinaryFile) + } + for _, header := range CurrentConfig.RequestHeaders { curlArgs = append(curlArgs, "-H", header) } diff --git a/src/protocurl.go b/src/protocurl.go index cac8b16..55e8fe1 100644 --- a/src/protocurl.go +++ b/src/protocurl.go @@ -90,7 +90,12 @@ var rootCmd = &cobra.Command{ func runProtocurlWorkflow() { protoRegistryFiles := convertProtoFilesToProtoRegistryFiles() - requestBinary := encodeToBinary(CurrentConfig.RequestType, CurrentConfig.DataText, protoRegistryFiles) + var requestBinary []byte // empty iff no body was provided or if an empty body was provided. + if CurrentConfig.Method == "GET" && CurrentConfig.RequestType == "" { + requestBinary = []byte{} + } else { + requestBinary = encodeToBinary(CurrentConfig.RequestType, CurrentConfig.DataText, protoRegistryFiles) + } responseBinary, responseHeaders := invokeHttpRequestBasedOnConfig(requestBinary) diff --git a/test/results/additional-curl-args-expected.txt b/test/results/additional-curl-args-expected.txt index ebcbd4b..406bb4d 100644 --- a/test/results/additional-curl-args-expected.txt +++ b/test/results/additional-curl-args-expected.txt @@ -10,7 +10,7 @@ includeReason: true =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:20:05 GMT +Date: Tue, 03 Oct 2023 20:42:35 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 65 diff --git a/test/results/additional-curl-args-verbose-expected.txt b/test/results/additional-curl-args-verbose-expected.txt index 305aab2..f8f9ccb 100644 --- a/test/results/additional-curl-args-verbose-expected.txt +++ b/test/results/additional-curl-args-verbose-expected.txt @@ -251,12 +251,12 @@ Total curl args: -s -X POST - --data-binary - @ --output --dump-header + --data-binary + @ -H Content-Type: application/x-protobuf -v @@ -279,7 +279,7 @@ Total curl args: * Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < Content-Type: application/x-protobuf -< Date: Fri, 29 Sep 2023 23:20:05 GMT +< Date: Tue, 03 Oct 2023 20:42:36 GMT < Connection: keep-alive < Keep-Alive: timeout=5 < Content-Length: 65 @@ -290,7 +290,7 @@ Total curl args: =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:20:05 GMT +Date: Tue, 03 Oct 2023 20:42:36 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 65 diff --git a/test/results/display-binary-and-headers-expected.txt b/test/results/display-binary-and-headers-expected.txt index 17fdfca..406bb4d 100644 --- a/test/results/display-binary-and-headers-expected.txt +++ b/test/results/display-binary-and-headers-expected.txt @@ -10,7 +10,7 @@ includeReason: true =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:20:04 GMT +Date: Tue, 03 Oct 2023 20:42:35 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 65 diff --git a/test/results/display-binary-and-headers-no-curl-expected.txt b/test/results/display-binary-and-headers-no-curl-expected.txt index cb4fa64..ea8376e 100644 --- a/test/results/display-binary-and-headers-no-curl-expected.txt +++ b/test/results/display-binary-and-headers-no-curl-expected.txt @@ -12,7 +12,7 @@ HTTP/1.1 200 OK Content-Length: 65 Connection: keep-alive Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:20:04 GMT +Date: Tue, 03 Oct 2023 20:42:35 GMT Keep-Alive: timeout=5 =========================== POST Response Binary =========================== <<< 00000000 08 01 12 1c 54 68 75 72 73 64 61 79 20 69 73 20 |....Thursday is | diff --git a/test/results/echo-empty-with-curl-args-expected.txt b/test/results/echo-empty-with-curl-args-expected.txt index a294af0..21dfa45 100644 --- a/test/results/echo-empty-with-curl-args-expected.txt +++ b/test/results/echo-empty-with-curl-args-expected.txt @@ -16,7 +16,7 @@ includeReason: true * Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < Content-Type: application/x-protobuf -< Date: Fri, 29 Sep 2023 23:20:13 GMT +< Date: Tue, 03 Oct 2023 20:42:44 GMT < Connection: keep-alive < Keep-Alive: timeout=5 < Content-Length: 2 diff --git a/test/results/far-future-json--v-expected.txt b/test/results/far-future-json--v-expected.txt index ae867c3..f094650 100644 --- a/test/results/far-future-json--v-expected.txt +++ b/test/results/far-future-json--v-expected.txt @@ -246,19 +246,19 @@ Total curl args: -s -X POST - --data-binary - @ --output --dump-header + --data-binary + @ -H Content-Type: application/x-protobuf http://localhost:8080/happy-day/verify =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:20:07 GMT +Date: Tue, 03 Oct 2023 20:42:38 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 63 diff --git a/test/results/far-future-json-no-curl-expected.txt b/test/results/far-future-json-no-curl-expected.txt deleted file mode 100644 index 02c6f32..0000000 --- a/test/results/far-future-json-no-curl-expected.txt +++ /dev/null @@ -1,5 +0,0 @@ -######### STDOUT ######### -######### STDERR ######### -proto: syntax error (line 1:1): invalid field name: { -panic: proto: syntax error (line 1:1): invalid field name: { - diff --git a/test/results/help-expected.txt b/test/results/help-expected.txt index 4de83a2..10a2872 100644 --- a/test/results/help-expected.txt +++ b/test/results/help-expected.txt @@ -23,13 +23,13 @@ Flags: --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -h, --help help for protocurl --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST (default) and GET supported. Other methods are passed on on to curl optimistically. (default "POST") + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on on to curl optimistically. (default "POST") --no-curl Forces the use of the built-in internal http request instead of curl. -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. @@ -38,7 +38,7 @@ Flags: --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Mandatory: Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. E.g. mypackage.MyRequest or ..MyRequest + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to diff --git a/test/results/help-missing-curl-expected.txt b/test/results/help-missing-curl-expected.txt index 4de83a2..10a2872 100644 --- a/test/results/help-missing-curl-expected.txt +++ b/test/results/help-missing-curl-expected.txt @@ -23,13 +23,13 @@ Flags: --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -h, --help help for protocurl --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST (default) and GET supported. Other methods are passed on on to curl optimistically. (default "POST") + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on on to curl optimistically. (default "POST") --no-curl Forces the use of the built-in internal http request instead of curl. -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. @@ -38,7 +38,7 @@ Flags: --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Mandatory: Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. E.g. mypackage.MyRequest or ..MyRequest + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to diff --git a/test/results/help-missing-curl-no-curl-expected.txt b/test/results/help-missing-curl-no-curl-expected.txt index 4de83a2..10a2872 100644 --- a/test/results/help-missing-curl-no-curl-expected.txt +++ b/test/results/help-missing-curl-no-curl-expected.txt @@ -23,13 +23,13 @@ Flags: --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -h, --help help for protocurl --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST (default) and GET supported. Other methods are passed on on to curl optimistically. (default "POST") + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on on to curl optimistically. (default "POST") --no-curl Forces the use of the built-in internal http request instead of curl. -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. @@ -38,7 +38,7 @@ Flags: --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Mandatory: Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. E.g. mypackage.MyRequest or ..MyRequest + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to diff --git a/test/results/help-no-curl-expected.txt b/test/results/help-no-curl-expected.txt index 4de83a2..10a2872 100644 --- a/test/results/help-no-curl-expected.txt +++ b/test/results/help-no-curl-expected.txt @@ -23,13 +23,13 @@ Flags: --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -h, --help help for protocurl --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST (default) and GET supported. Other methods are passed on on to curl optimistically. (default "POST") + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on on to curl optimistically. (default "POST") --no-curl Forces the use of the built-in internal http request instead of curl. -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. @@ -38,7 +38,7 @@ Flags: --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Mandatory: Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. E.g. mypackage.MyRequest or ..MyRequest + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to diff --git a/test/results/inferred-message-package-path-expected.txt b/test/results/inferred-message-package-path-expected.txt index 6da43e2..6d5a293 100644 --- a/test/results/inferred-message-package-path-expected.txt +++ b/test/results/inferred-message-package-path-expected.txt @@ -248,19 +248,19 @@ Total curl args: -s -X POST - --data-binary - @ --output --dump-header + --data-binary + @ -H Content-Type: application/x-protobuf http://localhost:8080/happy-day/verify =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:19:51 GMT +Date: Tue, 03 Oct 2023 20:42:21 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 68 diff --git a/test/results/inferred-message-package-path-name-clash-explicit-path-expected.txt b/test/results/inferred-message-package-path-name-clash-explicit-path-expected.txt index 65c0195..3e20592 100644 --- a/test/results/inferred-message-package-path-name-clash-explicit-path-expected.txt +++ b/test/results/inferred-message-package-path-name-clash-explicit-path-expected.txt @@ -313,19 +313,19 @@ Total curl args: -s -X POST - --data-binary - @ --output --dump-header + --data-binary + @ -H Content-Type: application/x-protobuf http://localhost:8080/happy-day/verify =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:19:55 GMT +Date: Tue, 03 Oct 2023 20:42:25 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 68 diff --git a/test/results/json-in-pretty-expected.txt b/test/results/json-in-pretty-expected.txt deleted file mode 100644 index cfb0693..0000000 --- a/test/results/json-in-pretty-expected.txt +++ /dev/null @@ -1,5 +0,0 @@ -######### STDOUT ######### -######### STDERR ######### -Unknown input format json:pretty. Expected text or json for --in -panic: Unknown input format json:pretty. Expected text or json for --in - diff --git a/test/results/json-in-text-out-expected.txt b/test/results/json-in-text-out-expected.txt deleted file mode 100644 index 02d8ce7..0000000 --- a/test/results/json-in-text-out-expected.txt +++ /dev/null @@ -1,223 +0,0 @@ -######### STDOUT ######### -Inferred input text type as JSON. -protocurl , build , https://github.com/qaware/protocurl -Adding default header argument to request headers : [Content-Type: application/x-protobuf] -Invoked with following default & parsed arguments: -{ - "ProtoFilesDir": "/proto", - "ProtoInputFilePath": "happyday.proto", - "RequestType": "happyday.HappyDayRequest", - "ResponseType": "happyday.HappyDayResponse", - "Url": "http://localhost:8080/happy-day/verify", - "DataText": "{ includeReason: true, date: { seconds: 1648044939, nanos: 152000000 } }", - "InTextType": "json", - "OutTextType": "text", - "DisplayBinaryAndHttp": true, - "RequestHeaders": [ - "Content-Type: application/x-protobuf" - ], - "CustomCurlPath": "", - "AdditionalCurlArgs": "", - "Verbose": true, - "ShowOutputOnly": false, - "ForceNoCurl": false, - "ForceCurl": false, - "GlobalProtoc": false, - "CustomProtocPath": "" -} -Found bundled protoc at /protocurl/protocurl-internal/bin/protoc -Using google protobuf include: /protocurl/protocurl-internal/include -=========================== .proto descriptor =========================== -file: { - name: "google/protobuf/timestamp.proto" - package: "google.protobuf" - message_type: { - name: "Timestamp" - field: { - name: "seconds" - number: 1 - label: LABEL_OPTIONAL - type: TYPE_INT64 - json_name: "seconds" - } - field: { - name: "nanos" - number: 2 - label: LABEL_OPTIONAL - type: TYPE_INT32 - json_name: "nanos" - } - } - options: { - java_package: "com.google.protobuf" - java_outer_classname: "TimestampProto" - java_multiple_files: true - go_package: "google.golang.org/protobuf/types/known/timestamppb" - cc_enable_arenas: true - objc_class_prefix: "GPB" - csharp_namespace: "Google.Protobuf.WellKnownTypes" - } - syntax: "proto3" -} -file: { - name: "happyday.proto" - package: "happyday" - dependency: "google/protobuf/timestamp.proto" - message_type: { - name: "HappyDayRequest" - field: { - name: "date" - number: 1 - label: LABEL_OPTIONAL - type: TYPE_MESSAGE - type_name: ".google.protobuf.Timestamp" - json_name: "date" - } - field: { - name: "includeReason" - number: 2 - label: LABEL_OPTIONAL - type: TYPE_BOOL - json_name: "includeReason" - } - field: { - name: "double" - number: 3 - label: LABEL_OPTIONAL - type: TYPE_DOUBLE - json_name: "double" - } - field: { - name: "int32" - number: 4 - label: LABEL_OPTIONAL - type: TYPE_INT32 - json_name: "int32" - } - field: { - name: "int64" - number: 5 - label: LABEL_OPTIONAL - type: TYPE_INT64 - json_name: "int64" - } - field: { - name: "string" - number: 6 - label: LABEL_OPTIONAL - type: TYPE_STRING - json_name: "string" - } - field: { - name: "bytes" - number: 7 - label: LABEL_OPTIONAL - type: TYPE_BYTES - json_name: "bytes" - } - field: { - name: "fooEnum" - number: 8 - label: LABEL_OPTIONAL - type: TYPE_ENUM - type_name: ".happyday.Foo" - json_name: "fooEnum" - } - field: { - name: "misc" - number: 9 - label: LABEL_REPEATED - type: TYPE_MESSAGE - type_name: ".happyday.MiscInfo" - json_name: "misc" - } - field: { - name: "float" - number: 10 - label: LABEL_OPTIONAL - type: TYPE_FLOAT - json_name: "float" - } - } - message_type: { - name: "HappyDayResponse" - field: { - name: "isHappyDay" - number: 1 - label: LABEL_OPTIONAL - type: TYPE_BOOL - json_name: "isHappyDay" - } - field: { - name: "reason" - number: 2 - label: LABEL_OPTIONAL - type: TYPE_STRING - json_name: "reason" - } - field: { - name: "formattedDate" - number: 3 - label: LABEL_OPTIONAL - type: TYPE_STRING - json_name: "formattedDate" - } - field: { - name: "err" - number: 4 - label: LABEL_OPTIONAL - type: TYPE_STRING - json_name: "err" - } - } - message_type: { - name: "MiscInfo" - field: { - name: "weatherOfPastFewDays" - number: 1 - label: LABEL_REPEATED - type: TYPE_STRING - json_name: "weatherOfPastFewDays" - } - field: { - name: "fooString" - number: 2 - label: LABEL_OPTIONAL - type: TYPE_STRING - oneof_index: 0 - json_name: "fooString" - } - field: { - name: "fooEnum" - number: 3 - label: LABEL_OPTIONAL - type: TYPE_ENUM - type_name: ".happyday.Foo" - oneof_index: 0 - json_name: "fooEnum" - } - oneof_decl: { - name: "alternative" - } - } - enum_type: { - name: "Foo" - value: { - name: "BAR" - number: 0 - } - value: { - name: "BAZ" - number: 1 - } - value: { - name: "FAZ" - number: 2 - } - } - syntax: "proto3" -} -######### STDERR ######### -proto: syntax error (line 1:3): invalid value includeReason -panic: proto: syntax error (line 1:3): invalid value includeReason - diff --git a/test/results/json-in-text-output-expected.txt b/test/results/json-in-text-output-expected.txt index 6789beb..5441ba8 100644 --- a/test/results/json-in-text-output-expected.txt +++ b/test/results/json-in-text-output-expected.txt @@ -246,19 +246,19 @@ Total curl args: -s -X POST - --data-binary - @ --output --dump-header + --data-binary + @ -H Content-Type: application/x-protobuf http://localhost:8080/happy-day/verify =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:19:59 GMT +Date: Tue, 03 Oct 2023 20:42:29 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 68 diff --git a/test/results/missing-args-expected.txt b/test/results/missing-args-expected.txt index f73b00a..a0285b8 100644 --- a/test/results/missing-args-expected.txt +++ b/test/results/missing-args-expected.txt @@ -1,6 +1,6 @@ ######### STDOUT ######### ######### STDERR ######### -Error: required flag(s) "data-text","request-type","url" not set +Error: required flag(s) "url" not set Usage: protocurl [flags] -I proto-dir -i request-type -o response-type -u url -d request-text @@ -21,13 +21,13 @@ Flags: --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -h, --help help for protocurl --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST (default) and GET supported. Other methods are passed on on to curl optimistically. (default "POST") + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on on to curl optimistically. (default "POST") --no-curl Forces the use of the built-in internal http request instead of curl. -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. @@ -36,12 +36,12 @@ Flags: --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Mandatory: Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. E.g. mypackage.MyRequest or ..MyRequest + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to -v, --verbose Prints version and enables verbose output. Also activates -D. --version version for protocurl -Error: required flag(s) "data-text","request-type","url" not set +Error: required flag(s) "url" not set ######### EXIT 1 ######### diff --git a/test/results/missing-args-no-curl-expected.txt b/test/results/missing-args-no-curl-expected.txt index f73b00a..a0285b8 100644 --- a/test/results/missing-args-no-curl-expected.txt +++ b/test/results/missing-args-no-curl-expected.txt @@ -1,6 +1,6 @@ ######### STDOUT ######### ######### STDERR ######### -Error: required flag(s) "data-text","request-type","url" not set +Error: required flag(s) "url" not set Usage: protocurl [flags] -I proto-dir -i request-type -o response-type -u url -d request-text @@ -21,13 +21,13 @@ Flags: --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -h, --help help for protocurl --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST (default) and GET supported. Other methods are passed on on to curl optimistically. (default "POST") + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on on to curl optimistically. (default "POST") --no-curl Forces the use of the built-in internal http request instead of curl. -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. @@ -36,12 +36,12 @@ Flags: --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Mandatory: Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. E.g. mypackage.MyRequest or ..MyRequest + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to -v, --verbose Prints version and enables verbose output. Also activates -D. --version version for protocurl -Error: required flag(s) "data-text","request-type","url" not set +Error: required flag(s) "url" not set ######### EXIT 1 ######### diff --git a/test/results/missing-args-partial-expected.txt b/test/results/missing-args-partial-expected.txt index ea0d5de..a0285b8 100644 --- a/test/results/missing-args-partial-expected.txt +++ b/test/results/missing-args-partial-expected.txt @@ -1,6 +1,6 @@ ######### STDOUT ######### ######### STDERR ######### -Error: required flag(s) "data-text","url" not set +Error: required flag(s) "url" not set Usage: protocurl [flags] -I proto-dir -i request-type -o response-type -u url -d request-text @@ -21,13 +21,13 @@ Flags: --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -h, --help help for protocurl --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST (default) and GET supported. Other methods are passed on on to curl optimistically. (default "POST") + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on on to curl optimistically. (default "POST") --no-curl Forces the use of the built-in internal http request instead of curl. -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. @@ -36,12 +36,12 @@ Flags: --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Mandatory: Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. E.g. mypackage.MyRequest or ..MyRequest + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to -v, --verbose Prints version and enables verbose output. Also activates -D. --version version for protocurl -Error: required flag(s) "data-text","url" not set +Error: required flag(s) "url" not set ######### EXIT 1 ######### diff --git a/test/results/missing-args-partial-no-curl-expected.txt b/test/results/missing-args-partial-no-curl-expected.txt index ea0d5de..a0285b8 100644 --- a/test/results/missing-args-partial-no-curl-expected.txt +++ b/test/results/missing-args-partial-no-curl-expected.txt @@ -1,6 +1,6 @@ ######### STDOUT ######### ######### STDERR ######### -Error: required flag(s) "data-text","url" not set +Error: required flag(s) "url" not set Usage: protocurl [flags] -I proto-dir -i request-type -o response-type -u url -d request-text @@ -21,13 +21,13 @@ Flags: --curl Forces the use of curl executable found in PATH. If none was found, then exits with an error. -C, --curl-args string Additional cURL args which will be passed on to cURL during request invocation for further configuration. Also activates --curl. --curl-path string Uses the given path to invoke curl instead of searching for curl in PATH. Also activates --curl. - -d, --data-text string Mandatory: The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. See https://github.com/qaware/protocurl + -d, --data-text string The payload data in Protobuf text format or JSON. It is inferred from the input as JSON if the first token is a '{'. The format can be set explicitly via --in. Mandatory if request-type is provided.See https://github.com/qaware/protocurl --decode-raw Decode the response into textual format without the schema by only showing field numbers and inferred field types. Types may be incorrect. Only output format text is supported. Use -o to see correct contents. -D, --display-binary-and-http Displays the binary request and response as well as the non-binary response headers. -h, --help help for protocurl --in string Specifies, in which format the input -d should be interpreted in. 'text' (default) uses the Protobuf text format and 'json' uses JSON. The type is inferred as JSON if the first token is a '{'. -F, --infer-files Infer the correct files containing the relevant protobuf messages. All proto files in the proto directory provided by -I will be used. If no -f is provided, this -F is set and the files are inferred. - -X, --method string HTTP request method. POST (default) and GET supported. Other methods are passed on on to curl optimistically. (default "POST") + -X, --method string HTTP request method. POST and GET are explicitly supported. Other methods are passed on on to curl optimistically. (default "POST") --no-curl Forces the use of the built-in internal http request instead of curl. -n, --no-default-headers Default headers (e.g. "Content-Type") will not be passed to curl. Assumes --curl. Use "-n -H 'Content-Type: FooBar'" to override the default content type. --out string Produces the output in the specified format. 'text' (default) produces Protobuf text format. 'json' produces dense JSON and 'json:pretty' produces pretty-printed JSON. The produced JSON always uses the original Protobuf field names instead of lowerCamelCasing them. @@ -36,12 +36,12 @@ Flags: --protoc Forces the use of a global protoc executable found in PATH or via --protoc-path instead of using the bundled one. If none was found, then exits with an error. --protoc-path string Uses the given path to invoke protoc instead of searching for protoc in PATH. Also activates --protoc. -H, --request-header string Adds the string header to the invocation of cURL. This option is not supported when --no-curl is active. E.g. -H 'MyHeader: FooBar'. - -i, --request-type string Mandatory: Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. E.g. mypackage.MyRequest or ..MyRequest + -i, --request-type string Message name or full package path of the Protobuf request type. The path can be shortened to '..', if the name of the request message is unique. Mandatory for POST requests. E.g. mypackage.MyRequest or ..MyRequest -o, --response-type string The Protobuf response type. See -i . Overrides --decode-raw. If not set, then --decode-raw is used. -q, --show-output-only Suppresses all output except response Protobuf as text. Overrides and deactivates -v and -D. Errors are still printed to stderr. -u, --url string Mandatory: The url to send the request to -v, --verbose Prints version and enables verbose output. Also activates -D. --version version for protocurl -Error: required flag(s) "data-text","url" not set +Error: required flag(s) "url" not set ######### EXIT 1 ######### diff --git a/test/results/no-default-headers-with-custom-content-type-header-expected.txt b/test/results/no-default-headers-with-custom-content-type-header-expected.txt index 826486d..a716f12 100644 --- a/test/results/no-default-headers-with-custom-content-type-header-expected.txt +++ b/test/results/no-default-headers-with-custom-content-type-header-expected.txt @@ -246,19 +246,19 @@ Total curl args: -s -X POST - --data-binary - @ --output --dump-header + --data-binary + @ -H Content-Type: application/octet-stream http://localhost:8080/happy-day/verify =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:20:19 GMT +Date: Tue, 03 Oct 2023 20:42:51 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 68 diff --git a/test/results/no-default-headers-with-no-additional-headers-expected.txt b/test/results/no-default-headers-with-no-additional-headers-expected.txt index 2900d8b..5d836ae 100644 --- a/test/results/no-default-headers-with-no-additional-headers-expected.txt +++ b/test/results/no-default-headers-with-no-additional-headers-expected.txt @@ -244,17 +244,17 @@ Total curl args: -s -X POST - --data-binary - @ --output --dump-header + --data-binary + @ http://localhost:8080/happy-day/verify =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:20:19 GMT +Date: Tue, 03 Oct 2023 20:42:50 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 68 diff --git a/test/results/other-days-are-happy-days-moved-protofiles-tmp-expected.txt b/test/results/other-days-are-happy-days-moved-protofiles-tmp-expected.txt deleted file mode 100644 index e69de29..0000000 diff --git a/test/results/response-type-arg-inferred-decode-raw-expected.txt b/test/results/response-type-arg-inferred-decode-raw-expected.txt index 560b21e..cb10960 100644 --- a/test/results/response-type-arg-inferred-decode-raw-expected.txt +++ b/test/results/response-type-arg-inferred-decode-raw-expected.txt @@ -248,19 +248,19 @@ Total curl args: -s -X POST - --data-binary - @ --output --dump-header + --data-binary + @ -H Content-Type: application/x-protobuf http://localhost:8080/happy-day/verify =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:19:54 GMT +Date: Tue, 03 Oct 2023 20:42:24 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 65 diff --git a/test/results/response-type-arg-overidden-decode-raw-expected.txt b/test/results/response-type-arg-overidden-decode-raw-expected.txt index 73a104c..3e98f68 100644 --- a/test/results/response-type-arg-overidden-decode-raw-expected.txt +++ b/test/results/response-type-arg-overidden-decode-raw-expected.txt @@ -247,19 +247,19 @@ Total curl args: -s -X POST - --data-binary - @ --output --dump-header + --data-binary + @ -H Content-Type: application/x-protobuf http://localhost:8080/happy-day/verify =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:19:54 GMT +Date: Tue, 03 Oct 2023 20:42:24 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 65 diff --git a/test/results/text-in-json-out-expected.txt b/test/results/text-in-json-out-expected.txt deleted file mode 100644 index 71efc2d..0000000 --- a/test/results/text-in-json-out-expected.txt +++ /dev/null @@ -1,259 +0,0 @@ -######### STDOUT ######### -Inferred input text type as Text. -protocurl , build , https://github.com/qaware/protocurl -Adding default header argument to request headers : [Content-Type: application/x-protobuf] -Invoked with following default & parsed arguments: -{ - "ProtoFilesDir": "/proto", - "ProtoInputFilePath": "happyday.proto", - "RequestType": "happyday.HappyDayRequest", - "ResponseType": "happyday.HappyDayResponse", - "Url": "http://localhost:8080/happy-day/verify", - "DataText": "includeReason: true, date: { seconds: 1648044939, nanos: 152000000 }", - "InTextType": "text", - "OutTextType": "json", - "DisplayBinaryAndHttp": true, - "RequestHeaders": [ - "Content-Type: application/x-protobuf" - ], - "CustomCurlPath": "", - "AdditionalCurlArgs": "", - "Verbose": true, - "ShowOutputOnly": false, - "ForceNoCurl": false, - "ForceCurl": false, - "GlobalProtoc": false, - "CustomProtocPath": "" -} -Found bundled protoc at /protocurl/protocurl-internal/bin/protoc -Using google protobuf include: /protocurl/protocurl-internal/include -=========================== .proto descriptor =========================== -file: { - name: "google/protobuf/timestamp.proto" - package: "google.protobuf" - message_type: { - name: "Timestamp" - field: { - name: "seconds" - number: 1 - label: LABEL_OPTIONAL - type: TYPE_INT64 - json_name: "seconds" - } - field: { - name: "nanos" - number: 2 - label: LABEL_OPTIONAL - type: TYPE_INT32 - json_name: "nanos" - } - } - options: { - java_package: "com.google.protobuf" - java_outer_classname: "TimestampProto" - java_multiple_files: true - go_package: "google.golang.org/protobuf/types/known/timestamppb" - cc_enable_arenas: true - objc_class_prefix: "GPB" - csharp_namespace: "Google.Protobuf.WellKnownTypes" - } - syntax: "proto3" -} -file: { - name: "happyday.proto" - package: "happyday" - dependency: "google/protobuf/timestamp.proto" - message_type: { - name: "HappyDayRequest" - field: { - name: "date" - number: 1 - label: LABEL_OPTIONAL - type: TYPE_MESSAGE - type_name: ".google.protobuf.Timestamp" - json_name: "date" - } - field: { - name: "includeReason" - number: 2 - label: LABEL_OPTIONAL - type: TYPE_BOOL - json_name: "includeReason" - } - field: { - name: "double" - number: 3 - label: LABEL_OPTIONAL - type: TYPE_DOUBLE - json_name: "double" - } - field: { - name: "int32" - number: 4 - label: LABEL_OPTIONAL - type: TYPE_INT32 - json_name: "int32" - } - field: { - name: "int64" - number: 5 - label: LABEL_OPTIONAL - type: TYPE_INT64 - json_name: "int64" - } - field: { - name: "string" - number: 6 - label: LABEL_OPTIONAL - type: TYPE_STRING - json_name: "string" - } - field: { - name: "bytes" - number: 7 - label: LABEL_OPTIONAL - type: TYPE_BYTES - json_name: "bytes" - } - field: { - name: "fooEnum" - number: 8 - label: LABEL_OPTIONAL - type: TYPE_ENUM - type_name: ".happyday.Foo" - json_name: "fooEnum" - } - field: { - name: "misc" - number: 9 - label: LABEL_REPEATED - type: TYPE_MESSAGE - type_name: ".happyday.MiscInfo" - json_name: "misc" - } - field: { - name: "float" - number: 10 - label: LABEL_OPTIONAL - type: TYPE_FLOAT - json_name: "float" - } - } - message_type: { - name: "HappyDayResponse" - field: { - name: "isHappyDay" - number: 1 - label: LABEL_OPTIONAL - type: TYPE_BOOL - json_name: "isHappyDay" - } - field: { - name: "reason" - number: 2 - label: LABEL_OPTIONAL - type: TYPE_STRING - json_name: "reason" - } - field: { - name: "formattedDate" - number: 3 - label: LABEL_OPTIONAL - type: TYPE_STRING - json_name: "formattedDate" - } - field: { - name: "err" - number: 4 - label: LABEL_OPTIONAL - type: TYPE_STRING - json_name: "err" - } - } - message_type: { - name: "MiscInfo" - field: { - name: "weatherOfPastFewDays" - number: 1 - label: LABEL_REPEATED - type: TYPE_STRING - json_name: "weatherOfPastFewDays" - } - field: { - name: "fooString" - number: 2 - label: LABEL_OPTIONAL - type: TYPE_STRING - oneof_index: 0 - json_name: "fooString" - } - field: { - name: "fooEnum" - number: 3 - label: LABEL_OPTIONAL - type: TYPE_ENUM - type_name: ".happyday.Foo" - oneof_index: 0 - json_name: "fooEnum" - } - oneof_decl: { - name: "alternative" - } - } - enum_type: { - name: "Foo" - value: { - name: "BAR" - number: 0 - } - value: { - name: "BAZ" - number: 1 - } - value: { - name: "FAZ" - number: 2 - } - } - syntax: "proto3" -} -=========================== Request Text =========================== >>> -date: { - seconds: 1648044939 - nanos: 152000000 -} -includeReason: true -=========================== Request Binary =========================== >>> -00000000 0a 0b 08 8b d7 ec 91 06 10 80 ac bd 48 10 01 |............H..| -Found curl: /usr/bin/curl -Invoking curl http request. -Understood additional curl args: [] -Total curl args: - -s - -X - POST - --data-binary - @ - --output - - --dump-header - - -H - Content-Type: application/x-protobuf - http://localhost:8080/happy-day/verify -=========================== Response Headers =========================== <<< -HTTP/1.1 200 OK -Content-Type: application/x-protobuf -Date: Sun, 17 Apr 2022 22:25:32 GMT -Connection: keep-alive -Keep-Alive: timeout=5 -Content-Length: 68 -=========================== Response Binary =========================== <<< -00000000 08 00 12 1f 54 6f 75 67 68 20 6c 75 63 6b 20 6f |....Tough luck o| -00000010 6e 20 57 65 64 6e 65 73 64 61 79 2e 2e 2e 20 f0 |n Wednesday... .| -00000020 9f 98 95 1a 1d 57 65 64 2c 20 32 33 20 4d 61 72 |.....Wed, 23 Mar| -00000030 20 32 30 32 32 20 31 34 3a 31 35 3a 33 39 20 47 | 2022 14:15:39 G| -00000040 4d 54 22 00 |MT".| -=========================== Response JSON =========================== <<< -{"reason":"Tough luck on Wednesday... 😕","formattedDate":"Wed, 23 Mar 2022 14:15:39 GMT"} -######### STDERR ######### diff --git a/test/results/text-in-json-output-expected.txt b/test/results/text-in-json-output-expected.txt index 0b2c5fd..a4c0ece 100644 --- a/test/results/text-in-json-output-expected.txt +++ b/test/results/text-in-json-output-expected.txt @@ -250,19 +250,19 @@ Total curl args: -s -X POST - --data-binary - @ --output --dump-header + --data-binary + @ -H Content-Type: application/x-protobuf http://localhost:8080/happy-day/verify =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:19:59 GMT +Date: Tue, 03 Oct 2023 20:42:29 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 68 diff --git a/test/results/verbose-custom-headers-expected.txt b/test/results/verbose-custom-headers-expected.txt index 0cfd708..c25a61c 100644 --- a/test/results/verbose-custom-headers-expected.txt +++ b/test/results/verbose-custom-headers-expected.txt @@ -252,12 +252,12 @@ Total curl args: -s -X POST - --data-binary - @ --output --dump-header + --data-binary + @ -H Content-Type: application/x-protobuf -H @@ -268,7 +268,7 @@ Total curl args: =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:20:03 GMT +Date: Tue, 03 Oct 2023 20:42:33 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 65 diff --git a/test/results/verbose-expected.txt b/test/results/verbose-expected.txt index 51b44b2..e1fa9ff 100644 --- a/test/results/verbose-expected.txt +++ b/test/results/verbose-expected.txt @@ -246,19 +246,19 @@ Total curl args: -s -X POST - --data-binary - @ --output --dump-header + --data-binary + @ -H Content-Type: application/x-protobuf http://localhost:8080/happy-day/verify =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:20:02 GMT +Date: Tue, 03 Oct 2023 20:42:32 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 65 diff --git a/test/results/verbose-long-args-equals-args-expected.txt b/test/results/verbose-long-args-equals-args-expected.txt index 51b44b2..560ff2e 100644 --- a/test/results/verbose-long-args-equals-args-expected.txt +++ b/test/results/verbose-long-args-equals-args-expected.txt @@ -246,19 +246,19 @@ Total curl args: -s -X POST - --data-binary - @ --output --dump-header + --data-binary + @ -H Content-Type: application/x-protobuf http://localhost:8080/happy-day/verify =========================== POST Response Headers =========================== <<< HTTP/1.1 200 OK Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:20:02 GMT +Date: Tue, 03 Oct 2023 20:42:33 GMT Connection: keep-alive Keep-Alive: timeout=5 Content-Length: 65 diff --git a/test/results/verbose-missing-curl-expected.txt b/test/results/verbose-missing-curl-expected.txt index 2c16156..4531e7e 100644 --- a/test/results/verbose-missing-curl-expected.txt +++ b/test/results/verbose-missing-curl-expected.txt @@ -250,7 +250,7 @@ HTTP/1.1 200 OK Content-Length: 65 Connection: keep-alive Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:20:03 GMT +Date: Tue, 03 Oct 2023 20:42:34 GMT Keep-Alive: timeout=5 =========================== POST Response Binary =========================== <<< 00000000 08 01 12 1c 54 68 75 72 73 64 61 79 20 69 73 20 |....Thursday is | diff --git a/test/results/verbose-no-curl-expected.txt b/test/results/verbose-no-curl-expected.txt index 539d711..3d7944f 100644 --- a/test/results/verbose-no-curl-expected.txt +++ b/test/results/verbose-no-curl-expected.txt @@ -246,7 +246,7 @@ HTTP/1.1 200 OK Content-Length: 65 Connection: keep-alive Content-Type: application/x-protobuf -Date: Fri, 29 Sep 2023 23:20:02 GMT +Date: Tue, 03 Oct 2023 20:42:32 GMT Keep-Alive: timeout=5 =========================== POST Response Binary =========================== <<< 00000000 08 01 12 1c 54 68 75 72 73 64 61 79 20 69 73 20 |....Thursday is | diff --git a/test/results/wednesday-is-not-a-happy-day-no-curl--X_GET-expected.txt b/test/results/wednesday-is-not-a-happy-day-no-curl--X_GET-expected.txt index cfd42d9..eac2dc3 100644 --- a/test/results/wednesday-is-not-a-happy-day-no-curl--X_GET-expected.txt +++ b/test/results/wednesday-is-not-a-happy-day-no-curl--X_GET-expected.txt @@ -5,8 +5,6 @@ date: { nanos: 152000000 } includeReason: true -=========================== GET Response Text =========================== <<< -reason: "Tough luck on Wednesday... 😕" -formattedDate: "Wed, 23 Mar 2022 14:15:39 GMT" ######### STDERR ######### -######### EXIT 0 ######### +Error: Internal Http implementation doesn't support GET requests with body. Please use curl. +######### EXIT 1 #########