Strange HTTP Socket connexion problem

Discussion in 'Perl Misc' started by axel@white-eagle.invalid.uk, Oct 16, 2005.

  1. Guest

    I'm having a strange problem trying to connect to a specific site
    with an HTTP request. Originally I was trying to send a SOAP request,
    but have whittled the script down to the most basic HTTP request
    possible:

    --- start
    #!/usr/bin/perl

    use strict;
    use warnings;
    use Socket;

    my $header = <<EOM;
    GET / HTTP/1.1
    Host: www.webservicex.net

    EOM

    socket (CLIENT, PF_INET, SOCK_STREAM, getprotobyname('tcp'))
    or die "socket: $!\n";
    bind (CLIENT, sockaddr_in(0, INADDR_ANY))
    or die "bind: $!\n";

    my $host = 'www.webservicex.net';
    my $rport = 80;
    my $ip_addr = inet_aton($host)
    or die "inet_aton: $!\n";
    my $rsockaddr = sockaddr_in($rport, $ip_addr);
    connect(CLIENT, $rsockaddr)
    or die "connect: $!\n";

    my $ofh = select CLIENT;
    $|++;
    select $ofh;

    print CLIENT $header;

    while (<CLIENT>) {
    print;
    }
    __END__

    For this particluar site (www.webservicex.net) the result is:

    --- start
    HTTP/1.1 400 Bad Request
    Content-Type: text/html
    Date: Sun, 16 Oct 2005 16:57:56 GMT
    Connection: close
    Content-Length: 20

    <h1>Bad Request</h1>
    --- end

    For *every* other site I have tried, it works perfectly. Also
    telneting to port 80 using a cut and paste from the $header
    defined above actually works - even stranger unless I am
    missing something very obvious.

    Axel
     
    , Oct 16, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. +The_Taco+

    SQL Connexion problem...

    +The_Taco+, Oct 17, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    399
    Kevin Spencer
    Oct 17, 2003
  2. =?Utf-8?B?VGhvbWFzQg==?=

    Unique user connexion to a web site [ASP.NET 2]

    =?Utf-8?B?VGhvbWFzQg==?=, Jun 2, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    484
    =?Utf-8?B?VGhvbWFzQg==?=
    Jun 2, 2005
  3. eldie

    database connexion check

    eldie, Jun 9, 2006, in forum: Java
    Replies:
    5
    Views:
    367
    shakah
    Jun 14, 2006
  4. Gilles Lenfant

    Linux/Python -> SQL*Server Connexion chain

    Gilles Lenfant, Sep 22, 2005, in forum: Python
    Replies:
    1
    Views:
    368
    Benji York
    Sep 22, 2005
  5. Beckam
    Replies:
    4
    Views:
    372
    Neil Coffey
    Jun 3, 2008
Loading...

Share This Page