We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,307 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Python HTTP Client unable to connect to server

Hey guys, can't see what is wrong with my code, I keep getting the error
Status: 500 Internal Server Error
Content-Type: text/html

<html><body><h1>500 Internal Server Error</h1></body></html>

import httplib
import sys
import time

#Initial connection to the server
def connectingToServer(port, message, path):
    connection = httplib.HTTPConnection('rpc248.cs.man.ac.uk', port)
    headers = {'Content-type': 'application/xml', 'Accept': 'application/xml'}
    connection.request('PUT', path, message, headers)
    print path, message, headers
    response = connection.getresponse()
    print response.status, response.reason
    return response
    
def get(port, username, password, path, message):
    path = path + '?username=' + username + '&password=' + password
    connection = httplib.HTTPConnection('rpc248.cs.man.ac.uk', port)
    connection.request('GET', path)
    response = connection.getresponse()
    print response.status, response.reason
    return response

username = 'buckled0'
password = 'EBqZRr'
requestID = time.time()
port = '3020'
message = '<reserve><request_id>'+str(requestID)+'</requestid><username>buckled0</username><password>EBqZRr</password><slot_id>100</slot_id></reserve>'
path = '/queue/enqueue'  
initialConnection = connectingToServer(port, message, path)
res = initialConnection.read()
if initialConnection.status == 200:
    print "Page has been found, outputting Request Body"
    print res
elif initialConnection.status == 404:
    print "Page not found"
elif initialConnection.status == 503:
    print "Service is unavailable"
elif initialConnection.status == 401:
    print "Invalid username/password"
2
Contributors
1
Reply
1 Month
Discussion Span
1 Year Ago
Last Updated
2
Views
djbuclkle
Newbie Poster
5 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

will u provide more details?

bishisht
Newbie Poster
6 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0912 seconds using 2.66MB