Invalid port number in request for secure site web page

Discussion in 'Python' started by jfdutcher1958, Oct 19, 2004.

  1. Python returns this message:

    InvalidURL: nonnumeric port: '//www.a2webhosting.com:2083/frontend/x2'

    in reponse to the call below ....but the port number looks
    numeric ???

    ***************************************************************
    import sys, httplib
    showlines = 56
    try:
    servername, filename = sys.argv[1:] # cmdline args?
    except:
    servername, filename
    = 'https://www.a2webhosting.com:2083/frontend/x2', '/index.html'

    print servername, filename
     
    jfdutcher1958, Oct 19, 2004
    #1
    1. Advertising

  2. "jfdutcher1958" <> writes:

    > Python returns this message:
    >
    > InvalidURL: nonnumeric port: '//www.a2webhosting.com:2083/frontend/x2'
    >
    > in reponse to the call below ....but the port number looks
    > numeric ???
    >
    > ***************************************************************
    > import sys, httplib
    > showlines = 56
    > try:
    > servername, filename = sys.argv[1:] # cmdline args?
    > except:
    > servername, filename
    > = 'https://www.a2webhosting.com:2083/frontend/x2', '/index.html'
    >
    > print servername, filename


    You've forgotten a line (the one which throws the error you've given).
    But, I believe your problem is 'https://www....' is parsed as a
    server:port pair: the server is https, and the port is //www..., which
    of course is invalid.

    I presume you're doing httplib.HTTPConnection(servername) (or
    HTTPSConnection). You can't use a URL there. Usage from the docs is
    like this:
    >>> h1 = httplib.HTTPConnection('www.cwi.nl')
    >>> h2 = httplib.HTTPConnection('www.cwi.nl:80')
    >>> h3 = httplib.HTTPConnection('www.cwi.nl', 80)


    Depending on what you're doing, you might be better off using the
    urllib or urllib2 modules.

    --
    |>|\/|<
    /--------------------------------------------------------------------------\
    |David M. Cooke
    |cookedm(at)physics(dot)mcmaster(dot)ca
     
    David M. Cooke, Oct 19, 2004
    #2
    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. A.M
    Replies:
    5
    Views:
    5,502
    Teemu Keiski
    Jun 8, 2004
  2. Replies:
    0
    Views:
    596
  3. Juan T. Llibre
    Replies:
    1
    Views:
    1,511
    =?Utf-8?B?Sm9obiBQYXVsLiBB?=
    Dec 8, 2006
  4. Replies:
    8
    Views:
    591
    Adrienne Boswell
    Jan 10, 2007
  5. mark | r
    Replies:
    1
    Views:
    147
    Hannibal
    Oct 7, 2003
Loading...

Share This Page