Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

logspam when reponse has no content #384

@jtnord

Description

@jtnord

Describe the bug

When a response to a request comes back from a server without any content type header the proxy creates a log entry

String contentType = HttpHeaders.getHeader(httpResponse, HttpHeaderNames.CONTENT_TYPE);
if (contentType == null) {
log.warn("No content type specified in response from {}. Content will be treated as {}", originalRequest.getUri(), BrowserUpHttpUtil.UNKNOWN_CONTENT_TYPE);
contentType = BrowserUpHttpUtil.UNKNOWN_CONTENT_TYPE;
}

This is all fine and dandy - but the log is a warning and is logged even when the response should not have any content, or may not have content and does not (and hence it would not have any content type either).

Various HTTP responses like some of the 3xx or even the 201/202 are not expected to contain content.

This can be seen with the Jenkins ATH https://github.com/jenkinsci/acceptance-test-harness.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Proxy with HAR captruing like the following:
            proxy = new BrowserUpProxyServer();
            // enable more detailed HAR capture, if desired (see CaptureType for the complete list)
            proxy.enableHarCaptureTypes(
                    CaptureType.REQUEST_HEADERS,
                    CaptureType.REQUEST_CONTENT,
                    CaptureType.RESPONSE_HEADERS,
                    CaptureType.RESPONSE_CONTENT
            );
            proxy.setTrustAllServers(true);
            proxy.start();
  1. go to any page that returns no content (like a redirect)
  2. See error

Expected behavior

The error is only logged if the page also has content.

there is no log (info / warning etc) if the response legitimately has no content. (this could be if the response is a set of specific codes)

Screenshots

If applicable, add screenshots to help explain your problem.

image

The response to the above request is

Please complete the following information:

  • OS: windows.
  • Browser firefox from selenium/standalone-firefox-debug:3.141.59
  • Version
  • version of browseup 2.1.2

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions