Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Nov 2010
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Getting Invalid Request Warning While Using Fsockopen

    Hello

    I am behind a proxy server and I want to make a request using fsockopen. But I am always getting a warning Invalid Request: Requested URL could not be retrieved.

    The code I am using is given below:

    PHP Code:
    <?php
    $fp 
    fsockopen("ps1.iiit-bh.ac.in"8080$errno$errstr30);
    if (!
    $fp) {
        echo 
    "$errstr ($errno)<br />\n";
    } else {
        
    $out "GET / HTTP/1.1\r\n";
        
    $out .= "Host: www.gadgeticworld.com\r\n";
        
    $out .= "Connection: Close\r\n\r\n";
        
    fwrite($fp$out);
        while (!
    feof($fp)) {
            echo 
    fgets($fp128);
        }
        
    fclose($fp);
    }
    ?>
    The error page looks like this:

    http://www.elaxtro.com/img1.bmp

    Any Help will be highly appreciated. I need to fix this issue.

    Thanks A Lot!

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Include the http:// in your URL.

  • #3
    New Coder
    Join Date
    Nov 2010
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fumigator View Post
    Include the http:// in your URL.
    After including http:// also it is not working. The same error page is being displayed.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Typically you don't want to specify the protocol within the name unless its using tls or udp. The protocol is inferred from the port that is in use, so just the dns name and socket are sufficient. Specifying http and a socket would try to map both, so it would logically look for http://http://dns.com, which definitely wouldn't work.

    I also cannot attach to that domain on either port 80 or 8080, so that simply indicates that it is invalid, as was the result of your return.

  • #5
    New Coder
    Join Date
    Nov 2010
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Typically you don't want to specify the protocol within the name unless its using tls or udp. The protocol is inferred from the port that is in use, so just the dns name and socket are sufficient. Specifying http and a socket would try to map both, so it would logically look for http://http://dns.com, which definitely wouldn't work.

    I also cannot attach to that domain on either port 80 or 8080, so that simply indicates that it is invalid, as was the result of your return.
    So, what is the solution to this problem?

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by Sandeep2010 View Post
    So, what is the solution to this problem?
    Well, its not a PHP issue. The DNS you've provided doesn't resolve to a machine - at least not on that port (and it won't respond to icmp traffic either). So the solution is to find a host that can be resolved.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •