Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-7432

Normalize the HTTP Host Header with the new HttpClientWrapper

    XMLWordPrintable

    Details

      Description

      The core problem with the HTTP Host Header has been explained on NMS-5884.

      Starting from 15, a big refactoring has been made in order to normalize the creation and usage of the HttpClient instances across the whole code base of OpenNMS, through a new class called HttpClientWrapper.

      Because the HttpClient library is always going to force the Host header, it would be very helpful to check the Host header format on the request before send it to the target host inside the wrapper implementation. That way, all the OpenNMS components that uses HttpClient (PageSequenceMonitor, WebMonitor, WebDetector, HttpCollector, XmlCollector, etc.) would benefit from it.

      As explained before, the problem is not the HttpClient, it is an issue of certain Web Servers like Microsoft IIS. The issue is: the web server complains if the host header includes the default ports (80 or 443 according with the selected schema) even knowing that adding the ports is valid according with the HTTP specificiation.

      So, the idea, is: if the Host header exist and it contains the default ports, remove the port and leave only the FQDN on the host header (at the wrapper level).

      Also, the PageSequenceMonitor provides a way to suppress the Host header, if the virtual-host parameter is not set on a page sequence. With the latest HttpClient, in order to suppress the host header, a request interceptor must be configured for this purpose, otherwise it is always going to be sent (which is the behavior in latest 1.12 and 14).

        Attachments

          Activity

            People

            • Assignee:
              agalue Alejandro Galue
              Reporter:
              agalue Alejandro Galue
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: