diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 9a629234..f699028f 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -16,12 +16,12 @@ jobs: os: [ubuntu-latest, windows-latest, macOS-latest] steps: - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: 1.21.x - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build run: go build . diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index 5f64731b..3bd3e765 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -14,15 +14,15 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: 1.21.x - name: Run golangci-lint - uses: golangci/golangci-lint-action@v3.6.0 + uses: golangci/golangci-lint-action@v6 with: version: latest args: --timeout 5m diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index bbd28d6b..1d60a0ec 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -11,17 +11,17 @@ jobs: runs-on: ubuntu-latest-16-cores steps: - name: "Check out code" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: "Set up Go" - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: 1.21.x - name: "Create release on GitHub" - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v6 with: args: "release --rm-dist" version: latest diff --git a/.github/workflows/release-test.yml b/.github/workflows/release-test.yml index 446e4777..aee4dc67 100644 --- a/.github/workflows/release-test.yml +++ b/.github/workflows/release-test.yml @@ -12,17 +12,17 @@ jobs: runs-on: ubuntu-latest-16-cores steps: - name: "Check out code" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: 1.21.x - name: release test - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v6 with: args: "release --clean --snapshot" version: latest diff --git a/internal/runner/runner.go b/internal/runner/runner.go index d7a5a292..d44a10fb 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -138,5 +138,5 @@ func (r *Runner) Close() { func printDslCompileError(err error) { gologger.Error().Msgf("error compiling DSL: %s", err) gologger.Info().Msgf("The available custom DSL functions are:") - gologger.Info().Label("").Msgf(dsl.GetPrintableDslFunctionSignatures(false)) + gologger.Info().Label("").Msg(dsl.GetPrintableDslFunctionSignatures(false)) } diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index ee28ca7b..b4f850e3 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -101,8 +101,15 @@ func NewLogger(options *OptionsLogger) *Logger { // LogRequest and user data func (l *Logger) LogRequest(req *http.Request, userdata types.UserData) error { - // No-op for now , since proxify isn't intended to fail instead return 502 - // and request can be accessed via response.Request + if req == nil { + return nil + } + + // send to writer channel + l.asyncqueue <- types.HTTPTransaction{ + Userdata: userdata, + Request: req, + } return nil } @@ -168,10 +175,12 @@ func (l *Logger) AsyncWrite() { URL: httpData.Request.URL.String(), } defer func() { - // write to structured writer with whatever data we have - err := l.sWriter.Write(sData) - if err != nil { - gologger.Warning().Msgf("Error while logging: %s", err) + if sData.Response != nil { + // write to structured writer with whatever data we have + err := l.sWriter.Write(sData) + if err != nil { + gologger.Warning().Msgf("Error while logging: %s", err) + } } }() sRequest, err := types.NewHttpRequestData(httpData.Request) diff --git a/pkg/types/userdata.go b/pkg/types/userdata.go index 44d44b65..84a1c07a 100644 --- a/pkg/types/userdata.go +++ b/pkg/types/userdata.go @@ -76,7 +76,7 @@ func NewHttpRequestData(req *http.Request) (*HTTPRequest, error) { httpRequest.Body = string(reqBody) // Extract raw request - reqdumpNoBody, err := httputil.DumpRequest(req, false) + reqdumpNoBody, err := httputil.DumpRequest(req, true) if err != nil { return nil, err } diff --git a/proxy.go b/proxy.go index 78b5bd88..ac8ea96d 100644 --- a/proxy.go +++ b/proxy.go @@ -200,6 +200,9 @@ func NewProxy(options *Options) (*Proxy, error) { // ModifyRequest func (p *Proxy) ModifyRequest(req *http.Request) error { + // // Set Content-Length to zero to allow automatic calculation + req.ContentLength = -1 + ctx := martian.NewContext(req) // disable upgrading http connections to https by default ctx.Session().MarkInsecure()