Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-660

Should host header be send in all lowercase

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • 3.1 RC1
    • 4.0 Alpha 1
    • None
    • None
    • Windows XP
      Sun 1.6_01 JVM

    Description

      Current the host header is sent as is from any 302 or standard url request. Now obviously according to the spec host names should be compared case insensitive but this isn't always the case. Most if not all browser will always lowercase the domain names when a request is sent. This problem happened when we were trying to valid urls from merchants. The one in particular was

      http://www.jdoqocy.com/click-1916095-10274762

      which will finally end up redirecting to

      http://www.BestArt.com/default.asp?aff=1

      With that case in the domain name and that is the way the host header is written. This will actually return a 404 if you request this URL from commons-httpclient, but will give no problem with a request in IE or FireFox b/c they lowercase the domain name before sending. This is b/c its trying to match BestArt instead of bestart. Now I know this isn't a problem with commons-httpclient but rather how they have their server configured. I think it would be nice to provide a property for this configuration settting or rather follow the way all browsers handle this as well.

      I know this isn't a major issue and was able to get around it by just sub classing the GetMethod and overriding addRequestHeader.

      @Override
      public void addRequestHeader(Header header) {
      if(header.getName().equalsIgnoreCase("host"))

      { header = new Header(header.getName(), header.getValue().toLowerCase(), header.isAutogenerated()); }

      super.addRequestHeader(header);
      }

      Just thought this may be of interest as well as it is quite a simple fix.

      Attachments

        Activity

          People

            Unassigned Unassigned
            split3 Daniel Hopper
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: