Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Pycurl proxy authentication anyone?

Reply
Thread Tools

Pycurl proxy authentication anyone?

 
 
Mark Ferguson
Guest
Posts: n/a
 
      11-05-2003
I've been trying to get a simple pycurl script working with an
authenticating proxy, here is the code (with changes to protect the
guilty!):

from pycurl import *
import StringIO

b = StringIO.StringIO()
c = Curl()

c.setopt(URL, "http://www.google.com/")
c.setopt(VERBOSE,1)
c.setopt(HTTPHEADER, ["User-Agent: Mozilla/5.001 (windows; U; NT4.0;
en-us) Gecko/25250101", "Agent: "])
c.setopt(PROXY, "dummyproxy")
c.setopt(PROXYPORT,80)
c.setopt(PROXYUSERPWD,"dummyuser:dummypasswd")
c.setopt(HTTPAUTH, #NTLM
c.setopt(WRITEFUNCTION, b.write)
c.setopt(FOLLOWLOCATION, 1)
c.setopt(MAXREDIRS, 5)

c.perform()
print b.getvalue()

And I get....

* About to connect() to dummyproxy:80
* Connected to dummyproxy (10.10.10.10) port 80
> GET http://www.google.com/ HTTP/1.1

Proxy-authorization: Basic ZHVtbXl1c2VyOmR1bW15cGFzc3dk
Authorization: NTLM TlRMTVNTUAABAAAAAgIAAAAAAAAgAAAAAAAAACAAAAA=
Host: www.google.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
User-Agent: Mozilla/5.001 (windows; U; NT4.0; en-us) Gecko/25250101

< HTTP/1.1 407 Proxy authentication required
< Proxy-Authenticate: NTLM
< Proxy-Connection: close
< Content-Length: 503
< Content-Type: text/html
* Connection #0 left intact
<html><head><title>Error 407</title>

<meta name="robots" content="noindex">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;
charset=iso-8859-1"></head>

<body>

<h2>HTTP Error 407</h2>

<p><strong>407 Proxy Authentication Required</strong></p>

<p>You must authenticate with a proxy server before this request can be
service
nd then try again.</p>

<p>Please contact the Web server's administrator if this problem
persists.</p>

</body></html>
* Closing connection #0

The usernameassword combo are correct.

I'm stumped! suggestions gratefully accepted..

Mark.



 
Reply With Quote
 
 
 
 
JanC
Guest
Posts: n/a
 
      11-07-2003
Mark Ferguson <> schreef:

> I've been trying to get a simple pycurl script working with an
> authenticating proxy, here is the code (with changes to protect the
> guilty!):


> c.setopt(PROXYPORT,80)
> c.setopt(PROXYUSERPWD,"dummyuser:dummypasswd")
> c.setopt(HTTPAUTH, #NTLM


Shouldn't that last line be:

c.setopt(PROXYAUTH, #NTLM

--
JanC

"Be strict when sending and tolerant when receiving."
RFC 1958 - Architectural Principles of the Internet - section 3.9
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use socks5 proxy in pycurl? Ju Hui Python 4 04-21-2006 06:35 PM
how to install PYCURL 7.15.2 on windows 2003? Ju Hui Python 1 04-13-2006 08:58 AM
Help getting started with Pycurl / libcurl ? gjzusenet@gmail.com Python 0 02-27-2006 11:58 AM
users of pycurl here? Michele Simionato Python 4 10-10-2005 09:06 AM
Read a binary file and feed it to PyCURL Jesse Noller Python 0 02-04-2004 02:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57