HttpClient- Read all resources headers for all resources for entire page



  • I need to check ETag from the header response of requesting URL. I know that when request URL, then response will be html, css, js and images.

    My issue: How to read header for all these resources including the html when requesting URL?

    For HttpClient if you enter URL then it will give header and response only for html!! it didn't return the header for all loading resources which are involved with this URL and will be loaded associated with this URL.

    if I request only css, then it will give me a right header response for this style.

    HttpClient client = HttpClientBuilder.create().build();
    HttpGet request = new HttpGet("http://www.mkyong.com/wp-content/themes/mkyong/css/prism.css");
    
    HttpResponse response = client.execute(request);
    for (Header header : response.getHeaders("ETag")) 
        System.out.println(header.getName()+" == "+header.getValue());
    

    But if I tried to but the main URL: http://www.mkyong.com, then it will give me only response for the main html.

    How to fetch them?



  • When your web browser requests a URL, the response is just the page and anything embedded in the page. Your web browser parses the response, determines what other resources are referenced by the page, and sends additional requests to fetch those resources, one resource per request.

    You will have to do the same thing.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2