Uploaded image for project: 'HttpComponents HttpCore'
  1. HttpComponents HttpCore
  2. HTTPCORE-760

An error occurred in the HttpClient 4.5 Tutorial document

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • 4.4.16
    • None
    • Documentation
    • None
    • Important

    Description

      Dear Apache HttpClient team,

      I would like to report a bug in the documentation for Apache HttpClient. Specifically, I have found an error in the section on  1.1.3. Working with message headers.(link: https://hc.apache.org/httpcomponents-client-4.5.x/current/tutorial/html/fundamentals.html )

      HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 
          HttpStatus.SC_OK, "OK");
      response.addHeader("Set-Cookie", 
          "c1=a; path=/; domain=localhost");
      response.addHeader("Set-Cookie", 
          "c2=b; path=\"/\", c3=c; domain=\"localhost\"");HeaderElementIterator it = new BasicHeaderElementIterator(
          response.headerIterator("Set-Cookie"));while (it.hasNext()) {
          HeaderElement elem = it.nextElement(); 
          System.out.println(elem.getName() + " = " + elem.getValue());
          NameValuePair[] params = elem.getParameters();
          for (int i = 0; i < params.length; i++) {
              System.out.println(" " + params[i]);
          }
      } 

      HttpClient 4.5 Tutorial  output result written in the document is:

      c1 = a
      path=/
      domain=localhost
      c2 = b
      path=/
      c3 = c
      domain=localhost 

      This is incorrect, the correct output should be:

      c1 = a
       path=/
       domain=localhost
      c2 = b
       path=/
      c3 = c
       domain=localhost 

      Could you please fix the format display? This may cause trouble for developers.

       

      Here are the pictures:

       

      Thank you for your attention to this matter.

      Sincerely

      Attachments

        Activity

          People

            Unassigned Unassigned
            hello2050 Mr.Z
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified