Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 699311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:22:20+00:00 2026-05-14T03:22:20+00:00

Take a look at this: WebClient client = new WebClient(); WebRequestSettings wrs = new

  • 0

Take a look at this:

WebClient client = new WebClient();
WebRequestSettings wrs = new WebRequestSettings(new URL("http://stackoverflow.com/ping/?what-the-duck?"), HttpMethod.HEAD);
client.getPage(wrs);

Running this code results in throwing FileNotFoundException, because HTTP Status code on the page is 404 and getting the same page again with the GET method, with User-Agent set to Java-.... Why does it GET the page (it doesn’t happen with “normal” status codes)? Is this a bug? Thanks

Here is the entire server response:

HTTP/1.1 404 Not Found
Cache-Control: private
Content-Length: 7502
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
Date: Thu, 11 Feb 2010 14:12:11 GMT

Where does it tell client to GET something? And how can I force WebClient to ignore it?

Here’s a screenshot of HTTPDebugger:
alt text

The problem here is I don’t understand why the second request is being sent and why is it sent with different useragent.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:22:21+00:00Added an answer on May 14, 2026 at 3:22 am

    You execute a HEAD request – this returns a response with null content. HtmlUnit nevertheless tries to create a page. To do so, it creates an input source with url and content (which is null) and gives it to a parser. An when a parser tries to parse the input source it sees a null content and uses the URL to retrieve the content anew. So it’s actually not the HtmlUnit which makes the second requests, it’s the XML parser. And that’s why the user agent is Java and not the HttpClient.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 538k
  • Answers 538k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You're correct, the second variant is the "good" one. Here's… May 17, 2026 at 1:54 am
  • Editorial Team
    Editorial Team added an answer You can always use PHP to stream the image from… May 17, 2026 at 1:54 am
  • Editorial Team
    Editorial Team added an answer The action parameter should be called genre instead of genreName… May 17, 2026 at 1:54 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Please take a look at this site as a reference: http://www.philsalesses.com/place-pulse/ On the left
could you take a look at this http://jsbin.com/osolo/ please? If you enter a letter
take a look at this validation demo: http://jquery.bassistance.de/validate/demo/ the error messages are placed on
Please take a look at this navigation: http://beta.viewcms.info/mint/ And you can see the hover
please take a look at the blue menu bar at the top of http://www.animefushigi.com
take a look at this example code: public class Comment { private Comment() {
Take a look at this example function: RuntimeConfiguration* conf_rt_conf() { RuntimeConfiguration *conf; conf =
Take a look at this demo , how do they accomplish the Inline Changes
Take a look at this html: <head> <title>Test page</title> <script type=text/javascript> function submitForm() {
Take a look at this SP. ALTER PROCEDURE [dbo].[sp_GetRecTitleVeh] AS BEGIN select a.StockNo, c.ClaimNo,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.