There are a lot of reasons you can get a 400-bad request error, most are due to malformed requests. But one in particular can happen if you are trying to access via an ip address number. Many places use what are called virtual hosts, that is the same computer services many webistes. Since they all share the same ip address number the way it can tell which one you are asking for is by a Host: header. But if you try to go to a website via a ip address number in a browser it will not include the host header or include the host: header with the ip address number. And so that webserver cannot tell which site you are trying to access and returns the 400 error.

For instance a friend of mine has a business website at http://jimstubblefieldfurniture.com. This is a shared webhost at the former yahoo. If you look up its ip address you find it is 67.195.61.46. but that is not the only website at that ip address. if you try to go to http://67.195.61.46 you get the "400 - bad request" error because it does not know what website you are trying to reach because it does not include a host header or instead includes a host:67.195.61.46 header

If you were using LWP to reach a site like this you could as LWP to include a proper Host: header with the dns name of the site you are going to, but i dont know of a way to ask a browser to do so.

Most of the reasons nslookup returns multiple ip numbers is for what is called load balancing. The numbers dont always get returned in the same order and your browser will use the first it finds. This results in the load being spread out over many servers. This is not really "dynamic ipaddresses" as the numbers dont change, just the order. In a case like that you still want to use the full name to access the website in a browser anyway.


In reply to Re^3: Connection to urls which are having dynamic ipadddresses through perl scripts by huck
in thread Connection to urls which are having dynamic ipadddresses through perl scripts by prathap keerthipati

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.