Why is ClientCookie/urllib2 using https?

Discussion in 'Python' started by Grant Edwards, Sep 24, 2003.

  1. In the program shown below, all of the connections to the
    servers are using port 443 and https (TLS protocol) -- both the
    initial connection to login.postini.com and subsequent
    connections to user-3.postini.com.

    It works, and I don't mind that it's encrypting the sessions as
    well as the login, but I'd like understand why the connections
    to "http://user-3.postini.com/exec/MsgCtr" are being done using
    TLS to port 443 instead of raw TCP to port 80 as is implied by
    the http: in the URL.

    FWIW, it's a program to delete quarantined viruse-laden
    messages from the server run by the Postini mail-filtering
    service. Viruses can only be deleted 10 at a time, and when
    you've got 7000 of them, that's a hell of a lot of mouse
    clicks. When they're coming in 200-300 an hour, automating the
    deleting process was the only reasonable solution.

    ---------------------------------8<---------------------------------
    import re,sys
    import ClientCookie
    import urllib,urllib2

    postData = urllib.urlencode({
    'remember':'1',
    'action':'login',
    'email':sys.argv[1],
    'pword':sys.argv[2]})

    req1 = urllib2.Request("https://login.postini.com/exec/login",data=postData)
    rsp1 = ClientCookie.urlopen(req1)

    req2 = urllib2.Request("http://user-3.postini.com/exec/MsgCtr")
    rsp2 = ClientCookie.urlopen(req2)

    while 1:
    data = rsp2.read()

    m = re.search('<form name=virus .*</form>',data,re.M|re.S)
    if not m:
    print "no virus form found"
    sys.exit()
    vdata = m.group()

    m = re.search('Message 1 - [0-9]+ of [0-9]+',vdata,re.M|re.S)
    if not m:
    print "did not find message count"
    sys.exit()
    print m.group()

    r = re.compile('<input type="checkbox" name="msgid" value="([^"]*)">',re.M|re.S)
    m = r.findall(vdata)

    if not m:
    print "no virus msgids found"
    sys.exit()

    postData = urllib.urlencode({'submit':'Remove','disp':'M','action':'change_Msgs'})
    for msgid in m:
    postData += "&msgid="+msgid

    req2 = urllib2.Request("http://user-3.postini.com/exec/MsgCtr",postData)
    rsp2 = ClientCookie.urlopen(req2)

    ---------------------------------8<---------------------------------

    --
    Grant Edwards grante Yow! He is the
    at MELBA-BEING... the ANGEL
    visi.com CAKE... XEROX him... XEROX
    him --
    Grant Edwards, Sep 24, 2003
    #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. Mark Carter

    ClientCookie bug

    Mark Carter, Aug 14, 2003, in forum: Python
    Replies:
    28
    Views:
    790
    John J. Lee
    Aug 27, 2003
  2. Chuck Bearden
    Replies:
    2
    Views:
    777
    Chuck Bearden
    May 11, 2004
  3. Michael Foord

    ClientCookie

    Michael Foord, Aug 11, 2004, in forum: Python
    Replies:
    11
    Views:
    745
    Michael Foord
    Aug 23, 2004
  4. Richie Hindle

    urllib2 / ClientCookie / Keep-Alive

    Richie Hindle, Oct 15, 2004, in forum: Python
    Replies:
    0
    Views:
    795
    Richie Hindle
    Oct 15, 2004
  5. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,739
    Smokey Grindel
    Dec 2, 2006
Loading...

Share This Page