[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2021-11-04 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
components: +Library (Lib), XML -email
nosy: +Arfrever, dmalcolm, ezio.melotti, flox, iankko, loewis, neologix, 
orsenthil, pitrou, python-dev, rosslagerwall, schmir -ahmedsayeed1982, barry, 
r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2021-11-04 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
Removed message: https://bugs.python.org/msg405710

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2021-11-04 Thread Ahmed Sayeed


Ahmed Sayeed  added the comment:

The glibc regular expression code mishandles regular expressions such as:

   .*((.)\2){2}$ https://www.webb-dev.co.uk/services/navona-trains/

as it does not backtrack enough to find a match that satisfies the 
back-references when they are used twice.
http://www.compilatori.com/computers/latest-car-deals/
To reproduce the problem, compile and run the attached file backrefbug.c. It 
will exit with status 2, whereas the correct exit status is 0.
 http://www.acpirateradio.co.uk/computers/latest-car-deals/
This bug was originally reported against GNU 'grep' here:
The glibc regular expression code mishandles regular expressions such as:

   .*((.)\2){2}$ http://www.logoarts.co.uk/computers/latest-car-deals/

as it does not backtrack enough to find a match that satisfies the 
back-references when they are used twice.

To reproduce the problem, compile and run the attached file backrefbug.c. It 
will exit with status 2, whereas the correct exit status is 0. 
http://www.slipstone.co.uk/computers/latest-car-deals/

This bug was originally reported against GNU 'grep' here:
The glibc regular expression code mishandles regular expressions such as: 
http://embermanchester.uk/computers/latest-car-deals/

   .*((.)\2){2}$

as it does not backtrack enough to find a match that satisfies the 
back-references when they are used twice. 
http://connstr.net/computers/latest-car-deals/

To reproduce the problem, compile and run the attached file backrefbug.c. It 
will exit with status 2, whereas the correct exit status is 0. 
http://joerg.li/computers/latest-car-deals/

This bug was originally reported against GNU 'grep' here:
The glibc regular expression code mishandles regular expressions such as:

   .*((.)\2){2}$ http://www.jopspeech.com/computers/latest-car-deals/

as it does not backtrack enough to find a match that satisfies the 
back-references when they are used twice.
 http://www.wearelondonmade.com/computers/latest-car-deals/
To reproduce the problem, compile and run the attached file backrefbug.c. It 
will exit with status 2, whereas the correct exit status is 0.
 https://waytowhatsnext.com/crypto/crypto-world/
This bug was originally reported against GNU 'grep' here:
The glibc regular expression code mishandles regular expressions such as:
http://www.iu-bloomington.com/crypto/latest-coins/
   .*((.)\2){2}$

as it does not backtrack enough to find a match that satisfies the 
back-references when they are used twice. 
https://komiya-dental.com/crypto/alt-coins/

To reproduce the problem, compile and run the attached file backrefbug.c. It 
will exit with status 2, whereas the correct exit status is 0. 
http://www-look-4.com/computers/latest-car-deals/

This bug was originally reported against GNU 'grep' here:

--
components: +email -Library (Lib), XML
nosy: +ahmedsayeed1982, barry, r.david.murray -Arfrever, dmalcolm, 
ezio.melotti, flox, iankko, loewis, neologix, orsenthil, pitrou, python-dev, 
rosslagerwall, schmir
versions:  -Python 2.6, Python 2.7, Python 3.2, Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22041] http POST request with python 3.3 through web proxy

2014-07-28 Thread Alejandro MJ

Alejandro MJ added the comment:

Thanks a lot for your help, as you suggested the problem was because of the 
method set_tunnel. I've tested the code that you have posted and now works 
perfectly.

I'll keep in mind this for future works. We can conclude that it's not really a 
bug of Python, so that this problem is related to proxy configuration. However, 
I'll take in count which version of Python to use if I have to do a similar job.

Regards,
Alejandro

--
resolution:  - not a bug

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22041] http POST request with python 3.3 through web proxy

2014-07-28 Thread Demian Brecht

Demian Brecht added the comment:

No problem, happy you were able to get things sorted. Feel free to close this 
issue as I've opened #22095 to address the host port header issue.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22041] http POST request with python 3.3 through web proxy

2014-07-28 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
stage:  - resolved
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22041] http POST request with python 3.3 through web proxy

2014-07-25 Thread Alejandro MJ

Alejandro MJ added the comment:

Thanks a lot for your help!

I've tested it in Linux, Python version 3.3.5 and the message obtained is this: 
[404 Not Found]. The script is this one (changing of course the ip_address and 
the proxy_url values):

import http.client, urllib.parse
data = urllib.parse.urlencode({'nombre': 'HERVAS INFANTE ALBERTO'})
headers = {Content-type: application/x-www-form-urlencoded}
conn = http.client.HTTPConnection(proxy_url,8080, source_address=(ip_address, 
0))
conn.set_tunnel(www.telexplorer.es,port=80)  
conn.request(POST, /?zone=namwp,data,headers)
response = conn.getresponse()
print(Test 1: TE - , response.status, response.reason)
data = response.read()
conn.close()


How could I test that patch attached? I suppose that I have to install 
something on Suse? As I could read in some forums, I should launch this 
sentence:

patch -p1 --dry-run  issue22041_1.patch

Could you please help me with this points? thanks!

--
nosy: +AlexMJ

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22041] http POST request with python 3.3 through web proxy

2014-07-25 Thread Alejandro MJ

Alejandro MJ added the comment:

I've wrote these sentences on my SUSE, python is installed on path: 
/usr/local/pr/python

computer002:/usr/local/pr/python # patch -p1 --dry-run issue22041_1.patch
can't find file to patch at input line 4
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--
|diff -r 5d70ac83d104 Lib/http/client.py
|--- a/Lib/http/client.py   Thu Jul 24 12:44:07 2014 +0200
|+++ b/Lib/http/client.py   Thu Jul 24 16:34:46 2014 -0700
--
File to patch: /usr/local/pr/python/lib/python3.3/http/client.py
patching file /usr/local/pr/python/lib/python3.3/http/client.py
Hunk #1 FAILED at 835.
1 out of 1 hunk FAILED -- saving rejects to file 
/usr/local/pr/python/lib/python3.3/http/client.py.rej
can't find file to patch at input line 17
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--
|diff -r 5d70ac83d104 Lib/test/test_httplib.py
|--- a/Lib/test/test_httplib.py Thu Jul 24 12:44:07 2014 +0200
|+++ b/Lib/test/test_httplib.py Thu Jul 24 16:34:46 2014 -0700
--
File to patch: /usr/local/pr/python/lib/python3.3/test/test_httplib.py
patching file /usr/local/pr/python/lib/python3.3/test/test_httplib.py
Hunk #1 FAILED at 1235.
1 out of 1 hunk FAILED -- saving rejects to file 
/usr/local/pr/python/lib/python3.3/test/test_httplib.py.rej
computer002:/usr/local/pr/python #
 
What am I doing wrong?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22041] http POST request with python 3.3 through web proxy

2014-07-25 Thread Demian Brecht

Demian Brecht added the comment:

To add a little more detail, from what I gather, CONNECT support may be 
unsupported or limited (i.e. only allowing SSL connections) on various proxy 
servers. If the code snippet in my previous post solves your issue, then I 
would assume that to be the case with the proxy you're using.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22041] http POST request with python 3.3 through web proxy

2014-07-25 Thread Demian Brecht

Demian Brecht added the comment:

Sorry Alejandro, I should have clarified: The attached patch is for dev, so the 
failure you're seeing when attempting to apply the patch against 3.3 is 
expected. It effectively does the same thing as explicitly setting the port as 
you have already attempted.

At this point, I'm relatively confident that the issue is due to the proxy 
server in use. Using your latest code but a local squid proxy, I'm able to get 
200 responses with the latest releases of 3.3 and 3.4 as well as against dev.

Do you absolutely need to tunnel? The most common use case for tunnelling is to 
use SSL, which doesn't seem to be the case here. Does the following code work 
for you? It still uses the proxy server, but without CONNECT.

import http.client, urllib.parse
data = urllib.parse.urlencode({'nombre': 'HERVAS INFANTE ALBERTO'})
headers = {Content-type: application/x-www-form-urlencoded}
conn = http.client.HTTPConnection(proxy_url,8080, source_address=(ip_address, 
0))
conn.request(POST, http://www.telexplorer.es/?zone=namwp,data,headers)
response = conn.getresponse()
print(Test 1: TE - , response.status, response.reason)
data = response.read()
conn.close()


If the above code doesn't fulfill your requirements, do you know the 
vendor/version of the proxy that you're using?


Note to self: 3.3 doesn't respect _tunnel_port when setting the host header for 
requests (this was added in 3.4), so CONNECT and subsequent host headers will 
appear to be correct as long as the ports match up. The problem 3.4+ is that 
rather than ensuring non-None value in set_tunnel, it's done in _tunnel as a 
step just before CONNECT. That step is not replicated when the host header is 
set in putrequest, which leads to the value of None being sent for the port 
in the case where the port is not explicitly set in set_tunnel. To me, it makes 
the most sense to use _set_hostport in set_tunnel as in the attached patch to 
ensure any other use of _tunnel_port can be done without special handling of 
None.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22041] http POST request with python 3.3 through web proxy

2014-07-24 Thread Demian Brecht

Demian Brecht added the comment:

I've attached a patch that solves the issue I encountered. It would be great if 
you could confirm whether or not it also resolves the issue as reported.

--
keywords: +patch
Added file: http://bugs.python.org/file36066/issue22041.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22041] http POST request with python 3.3 through web proxy

2014-07-24 Thread Demian Brecht

Demian Brecht added the comment:

Attached a new patch with with a simple test.

--
Added file: http://bugs.python.org/file36079/issue22041_1.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22041] http POST request with python 3.3 through web proxy

2014-07-23 Thread Alejandro Mj

Changes by Alejandro Mj witchar...@gmail.com:


--
nosy:  -AlexMJ

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22041] http POST request with python 3.3 through web proxy

2014-07-23 Thread Demian Brecht

Changes by Demian Brecht demianbre...@gmail.com:


--
nosy: +demian.brecht

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22041] http POST request with python 3.3 through web proxy

2014-07-23 Thread Demian Brecht

Demian Brecht added the comment:

Hi Alejandro,

I've spent a little time looking into this. I haven't been able to reproduce 
what you're seeing on Windows exactly, but I've encountered other issues along 
the same path using a local squid instance (localhost:4242):


from http.client import OK, HTTPConnection
import unittest

class TestProxy(unittest.TestCase):
def test_proxy_tunnel_success(self):
con = HTTPConnection('localhost', 4242)
con.set_tunnel('www.example.com')
con.request('GET', 'http://www.example.com')
resp = con.getresponse()
self.assertEqual(resp.code, 200)
data = resp.read()
con.close()

def test_proxy_tunnel_failure(self):
con = HTTPConnection('localhost', 4242)
con.set_tunnel('www.example.com')
con.request('GET', '/')
resp = con.getresponse()
self.assertEqual(resp.code, 200) # FAILS
con.close()

if __name__ == '__main__':
unittest.main()


As you can see with the test above, if I use the full URI, the request 
succeeds, but the relative path (as in your example) fails. My assumption is 
that these issues may be related to proxy server implementations, but I'd have 
to some further investigation before being able to go on more than a hunch (and 
I don't have time to do that tonight).

As a first step, could you please try using a full URI in your request and see 
if that produces the desired result?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22041] http POST request with python 3.3 through web proxy

2014-07-23 Thread Demian Brecht

Demian Brecht added the comment:

Ignore my previous note. Digging into this a little more, I think I've possibly 
found the underlying issue:

If the port is not specified in set_tunnel (as in your example), the buffer 
sent over the wire looks like

send: b'POST [PATH] HTTP/1.1\r\nHost: [HOST]:None\r\nAccept-Encoding: 
identity\r\nContent-Length: 41\r\nAccept: text/plain\r\nContent-type: 
application/x-www-form-urlencoded\r\n\r\n[FORM_DATA]'

Note the None as the port. However, if the port is explicitly set, then the 
resulting buffer looks like:

send: b'POST [PATH] HTTP/1.1\r\nHost: [HOST]:[PORT]\r\nAccept-Encoding: 
identity\r\nContent-Length: 41\r\nAccept: text/plain\r\nContent-type: 
application/x-www-form-urlencoded\r\n\r\n[FORM_DATA]'


Can you retry your example, but specify the port and let me know if that fixes 
your problem? Either way, this is a bug that I'll submit a patch (and test) 
for, but I'd like to know that it solves the issue as written.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22041] http POST request with python 3.3 through web proxy

2014-07-22 Thread Alejandro MJ

New submission from Alejandro MJ:

I'm trying this specific method with python, in order to use a different ip 
source, to do a POST request: 

import http.client, urllib.parse
data = urllib.parse.urlencode({'QLastname': 'DIAZ HERNANDEZ', 'QFirstname': 
'JAIME'})
headers = {Content-type: application/x-www-form-urlencoded,Accept: 
text/plain}
conn = http.client.HTTPConnection(www.infobel.com,80, 
source_address=(16.19.109.51, 0))
conn.request(POST, /es/spain/people.aspx, data, headers)
response = conn.getresponse()
print(response.status, response.reason)
data = response.read()
conn.close()

It works perfectly when I test it without a proxy, but when I try with proxy 
connection, I receive this error:

 conn.request(POST, /es/spain/people.aspx, data, headers)
Traceback (most recent call last):
  File stdin, line 1, in module
  File C:\Python34\lib\http\client.py, line 1090, in request
self._send_request(method, url, body, headers)
  File C:\Python34\lib\http\client.py, line 1128, in _send_request
self.endheaders(body)
  File C:\Python34\lib\http\client.py, line 1086, in endheaders
self._send_output(message_body)
  File C:\Python34\lib\http\client.py, line 924, in _send_output
self.send(msg)
  File C:\Python34\lib\http\client.py, line 859, in send
self.connect()
  File C:\Python34\lib\http\client.py, line 836, in connect
self.timeout, self.source_address)
  File C:\Python34\lib\socket.py, line 509, in create_connection
raise err
  File C:\Python34\lib\socket.py, line 500, in create_connection
sock.connect(sa)

TimeoutError: [WinError 10060] Se produjo un error durante el intento...

How could I follow proxy configuration in this script? 

This is the code I made to test with proxy (following the documentation of 
Python):

import http.client, urllib.parse
data = urllib.parse.urlencode({'QLastname': 'DIAZ HERNANDEZ', 'QFirstname': 
'JAIME'})
headers={Content-Type:application/x-www-form-urlencoded,Accept:text/plain}
conn = http.client.HTTPConnection(proxy_url,8080, source_address=(ipAddress, 0))
conn.set_tunnel(www.infobel.com)
conn.request(POST, /es/spain/people.aspx, data, headers)
response = conn.getresponse()
print(response.status, response.reason)
data = response.read()
conn.close()

I could't make it work in this SO:
SUSE Linux Enterprise Server 11 (x86_64) VERSION = 11 PATCHLEVEL = 2 

The message that proxy give us is this:

2014-07-22 08:31:49 87 16.19.109.51 23.2.2.22 - - - PROXIED none -  200 
TCP_ACCELERATED CONNECT - tcp www.infobel.com 80 / - - - 23.2.2.22 39 39 - 
2014-07-22 08:31:49 1  16.19.109.51 23.2.2.22 - - dns_unresolved_hostname 
PROXIED none -  404 TCP_ERR_MISS POST - http cachebdvg1.igrupobbva 8080 
/es/spain/people.aspx - aspx - 23.2.2.22 815 230 - 

So I tried to prove it in other SO, such as Windows, in a different computer. A 
curious thing... I've tried this with Python3.4.1 in Windows, and it didn't 
work. But when I proved with Python3.3.5 it works!! 

Thanks for help.

--
components: Windows
messages: 223688
nosy: AlexMJ
priority: normal
severity: normal
status: open
title: http POST request with python 3.3 through web proxy
type: behavior
versions: Python 3.4, Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: http post goes into $_REQUEST instead into $_FILES

2013-08-16 Thread Piet van Oostrum
cerr ron.egg...@gmail.com writes:

 Hi,

 I have a Python script that is executing an http POST to transfer a file from 
 the client to the server. I have achieved this with below code:

snip

 but my problem is, the data gets posted to the sever but arrives in
 the `$_REQUEST` array and I'm expected to post stuff so that it
 arrives in the `$_FILES` array (this is a LAMP server). How do I need
 to modify my code to deliver it correctly?

MultipartPostHandler only works like that if you give it a real file.

Like:

myfile = open('test.txt')
data = {'file': myfile}
response = opener.open(url, data)

'file' will be the key in the $_FILES array.

If you want to 'fake' a file by supplying your own contents and fake
filename, you can better use the code from Doug Hellmann:
http://pymotw.com/2/urllib2/#uploading-files

If you don't want to use his StringIO trick you could even add a new
method add_fake_file like this:

def add_fake_file(self, fieldname, filename, body, mimetype='text/plain'):
Add a fake file to be uploaded.
self.files.append((fieldname, filename, mimetype, body))
return

and then use it like:

form.add_fake_file('file', 'test1.txt', 'This is a test.')

-- 
Piet van Oostrum p...@vanoostrum.org
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
http://mail.python.org/mailman/listinfo/python-list


http post goes into $_REQUEST instead into $_FILES

2013-08-15 Thread cerr
Hi,

I have a Python script that is executing an http POST to transfer a file from 
the client to the server. I have achieved this with below code:

from binascii import hexlify, unhexlify
from httplib import HTTPConnection, HTTPException
import os
import hashlib
import socket
import urllib2
import time
import subprocess

import MultipartPostHandler

def post_file(filename, data):
try:
wakeup()
socket.setdefaulttimeout(TIMEOUT)
#create multipartpost handler
opener = 
urllib2.build_opener(MultipartPostHandler.MultipartPostHandler)
#set POST arguments
host = HOST
func = post_file
fname = filename
#assemble post URL
url = http://{0}{1}.format(host, URI)
print POSTING +fname
#assemble multipart header
data = {data:data,f:func,fname:filename}
#execute POST
response = opener.open(url, data, timeout=TIMEOUT)
#reads server return value
retval = response.read()
print retval
if SUCCESS in retval:
return 0
else:
print RETVAL: +retval
return 99
except Exception as e:
print EXCEPTION time +str(time.time())+ - +str(e)
return 99

but my problem is, the data gets posted to the sever but arrives in the 
`$_REQUEST` array and I'm expected to post stuff so that it arrives in the 
`$_FILES` array (this is a LAMP server). How do I need to modify my code to 
deliver it correctly?

Thank you,
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP post with urllib2

2013-08-07 Thread cerr
On Tuesday, August 6, 2013 5:14:48 PM UTC-7, MRAB wrote:
 On 06/08/2013 23:52, cerr wrote:
 
  Hi,
 
 
 
  Why does this code:
 
 
 
  #!/usr/bin/python
 
 
 
 
 
  import urllib2
 
  from binascii import hexlify, unhexlify
 
 
 
  host = localhost
 
  uri=/test.php
 
  data =\x48\x65\x6C\x6C\x6F\x57\x6F\x72\x6C\x64 #Hello World
 
  url=http://{0}{1}?f=test.format(host, uri)
 
  req = urllib2.Request(url, data,{'Content-Type': 
  'application/octet-stream'})
 
  req.get_method = lambda: 'PUT'
 
  response = urllib2.urlopen(req, 120)
 
  retval = response.read()
 
  print RETVAL +retval
 
 
 
 
 
 
 
  return me this:
 
 
 
  ./post.py
 
  Traceback (most recent call last):
 
 File ./post.py, line 13, in module
 
   response = urllib2.urlopen(req, 120)
 
 File /usr/lib/python2.7/urllib2.py, line 126, in urlopen
 
   return _opener.open(url, data, timeout)
 
 File /usr/lib/python2.7/urllib2.py, line 398, in open
 
   req = meth(req)
 
 File /usr/lib/python2.7/urllib2.py, line 1116, in do_request_
 
   'Content-length', '%d' % len(data))
 
 
 
 
 
  I don't get it, what's going on here?
 
 
 
 The docs say urllib2.urlopen(url[, data][, timeout]).
 
 
 
 You're calling it as urllib2.urlopen(req, 120).
 
 
 
 In other words, 'url' is req and 'data' is 120.
 
 
 
 It should be urllib2.urlopen(req, None, 120).

Yes, great! That did it! :)
Coming into the office in the morning, sitting down, changing this and get it 
working! Good way to start my day! :)

Thanks MRAB!
-- 
http://mail.python.org/mailman/listinfo/python-list


HTTP post with urllib2

2013-08-06 Thread cerr
Hi,

Why does this code:

#!/usr/bin/python


import urllib2
from binascii import hexlify, unhexlify

host = localhost
uri=/test.php
data =\x48\x65\x6C\x6C\x6F\x57\x6F\x72\x6C\x64 #Hello World
url=http://{0}{1}?f=test.format(host, uri)
req = urllib2.Request(url, data,{'Content-Type': 'application/octet-stream'})
req.get_method = lambda: 'PUT'
response = urllib2.urlopen(req, 120)
retval = response.read()
print RETVAL +retval



return me this:

./post.py
Traceback (most recent call last):
  File ./post.py, line 13, in module
response = urllib2.urlopen(req, 120)
  File /usr/lib/python2.7/urllib2.py, line 126, in urlopen
return _opener.open(url, data, timeout)
  File /usr/lib/python2.7/urllib2.py, line 398, in open
req = meth(req)
  File /usr/lib/python2.7/urllib2.py, line 1116, in do_request_
'Content-length', '%d' % len(data))


I don't get it, what's going on here?

Thank you!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP post with urllib2

2013-08-06 Thread Joel Goldstick
On Tue, Aug 6, 2013 at 6:52 PM, cerr ron.egg...@gmail.com wrote:
 Hi,

 Why does this code:

 #!/usr/bin/python


 import urllib2
 from binascii import hexlify, unhexlify

 host = localhost
 uri=/test.php
 data =\x48\x65\x6C\x6C\x6F\x57\x6F\x72\x6C\x64 #Hello World
 url=http://{0}{1}?f=test.format(host, uri)
 req = urllib2.Request(url, data,{'Content-Type': 'application/octet-stream'})
 req.get_method = lambda: 'PUT'

What does the above line do? is it the same as req.get_method = 'PUT'
 response = urllib2.urlopen(req, 120)

the docs say req should be a url.  Is it?
 retval = response.read()
 print RETVAL +retval



 return me this:

 ./post.py
 Traceback (most recent call last):
   File ./post.py, line 13, in module
 response = urllib2.urlopen(req, 120)
   File /usr/lib/python2.7/urllib2.py, line 126, in urlopen
 return _opener.open(url, data, timeout)
   File /usr/lib/python2.7/urllib2.py, line 398, in open
 req = meth(req)
   File /usr/lib/python2.7/urllib2.py, line 1116, in do_request_
 'Content-length', '%d' % len(data))


 I don't get it, what's going on here?

 Thank you!
 --
 http://mail.python.org/mailman/listinfo/python-list

KInda of ducking your questions, but the requests module is a lot
easier to use and
understand:http://docs.python-requests.org/en/latest/



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP post with urllib2

2013-08-06 Thread cerr
On Tuesday, August 6, 2013 4:08:34 PM UTC-7, Joel Goldstick wrote:
 On Tue, Aug 6, 2013 at 6:52 PM, cerr ron.egg...@gmail.com wrote:
 
  Hi,
 
 
 
  Why does this code:
 
 
 
  #!/usr/bin/python
 
 
 
 
 
  import urllib2
 
  from binascii import hexlify, unhexlify
 
 
 
  host = localhost
 
  uri=/test.php
 
  data =\x48\x65\x6C\x6C\x6F\x57\x6F\x72\x6C\x64 #Hello World
 
  url=http://{0}{1}?f=test.format(host, uri)
 
  req = urllib2.Request(url, data,{'Content-Type': 
  'application/octet-stream'})
 
  req.get_method = lambda: 'PUT'
 
 
 
 What does the above line do? is it the same as req.get_method = 'PUT'

I guess so, I got this from an example copy  paste :x

 
  response = urllib2.urlopen(req, 120)
 
 
 
 the docs say req should be a url.  Is it?

no, it's an instance of req = urllib2.Request()
 
  retval = response.read()
 
  print RETVAL +retval
 
 
 
 
 
 
 
  return me this:
 
 
 
  ./post.py
 
  Traceback (most recent call last):
 
File ./post.py, line 13, in module
 
  response = urllib2.urlopen(req, 120)
 
File /usr/lib/python2.7/urllib2.py, line 126, in urlopen
 
  return _opener.open(url, data, timeout)
 
File /usr/lib/python2.7/urllib2.py, line 398, in open
 
  req = meth(req)
 
File /usr/lib/python2.7/urllib2.py, line 1116, in do_request_
 
  'Content-length', '%d' % len(data))
 
 
 
 
 
  I don't get it, what's going on here?
 
 
 
  Thank you!
 
  --
 
  http://mail.python.org/mailman/listinfo/python-list
 
 
 
 KInda of ducking your questions, but the requests module is a lot
 
 easier to use and
 
 understand:http://docs.python-requests.org/en/latest/

But there must be a way to get this working with urllib alone...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP post with urllib2

2013-08-06 Thread Joel Goldstick
On Tue, Aug 6, 2013 at 7:35 PM, cerr ron.egg...@gmail.com wrote:
 On Tuesday, August 6, 2013 4:08:34 PM UTC-7, Joel Goldstick wrote:
 On Tue, Aug 6, 2013 at 6:52 PM, cerr ron.egg...@gmail.com wrote:

  Hi,

 

  Why does this code:

 

  #!/usr/bin/python

 

 

  import urllib2

  from binascii import hexlify, unhexlify

 

  host = localhost

  uri=/test.php

  data =\x48\x65\x6C\x6C\x6F\x57\x6F\x72\x6C\x64 #Hello World

  url=http://{0}{1}?f=test.format(host, uri)

  req = urllib2.Request(url, data,{'Content-Type': 
  'application/octet-stream'})

  req.get_method = lambda: 'PUT'



 What does the above line do? is it the same as req.get_method = 'PUT'

 I guess so, I got this from an example copy  paste :x

That's not a very good answer!  Honest, but really.  Just because you
can cut and paste, doesn't mean you are learning to program.


  response = urllib2.urlopen(req, 120)



 the docs say req should be a url.  Is it?

 no, it's an instance of req = urllib2.Request()

  retval = response.read()

  print RETVAL +retval

 

 

 

  return me this:

 

  ./post.py

  Traceback (most recent call last):

File ./post.py, line 13, in module

  response = urllib2.urlopen(req, 120)

File /usr/lib/python2.7/urllib2.py, line 126, in urlopen

  return _opener.open(url, data, timeout)

File /usr/lib/python2.7/urllib2.py, line 398, in open

  req = meth(req)

File /usr/lib/python2.7/urllib2.py, line 1116, in do_request_

  'Content-length', '%d' % len(data))

 

 

  I don't get it, what's going on here?

 

  Thank you!

  --

  http://mail.python.org/mailman/listinfo/python-list



 KInda of ducking your questions, but the requests module is a lot

 easier to use and

 understand:http://docs.python-requests.org/en/latest/

 But there must be a way to get this working with urllib alone...

I'm sure there is.  I'm not a pro at urllib, not even requests but
when I have used it, it made a lot more sense.

It got changed in python 3, so the python core group seemed not to
like how the earlier modules worked.

At any rate.  wait a while.  Someone on the list will give you more
specific advice I'm sure
 --
 http://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP post with urllib2

2013-08-06 Thread MRAB

On 06/08/2013 23:52, cerr wrote:

Hi,

Why does this code:

#!/usr/bin/python


import urllib2
from binascii import hexlify, unhexlify

host = localhost
uri=/test.php
data =\x48\x65\x6C\x6C\x6F\x57\x6F\x72\x6C\x64 #Hello World
url=http://{0}{1}?f=test.format(host, uri)
req = urllib2.Request(url, data,{'Content-Type': 'application/octet-stream'})
req.get_method = lambda: 'PUT'
response = urllib2.urlopen(req, 120)
retval = response.read()
print RETVAL +retval



return me this:

./post.py
Traceback (most recent call last):
   File ./post.py, line 13, in module
 response = urllib2.urlopen(req, 120)
   File /usr/lib/python2.7/urllib2.py, line 126, in urlopen
 return _opener.open(url, data, timeout)
   File /usr/lib/python2.7/urllib2.py, line 398, in open
 req = meth(req)
   File /usr/lib/python2.7/urllib2.py, line 1116, in do_request_
 'Content-length', '%d' % len(data))


I don't get it, what's going on here?


The docs say urllib2.urlopen(url[, data][, timeout]).

You're calling it as urllib2.urlopen(req, 120).

In other words, 'url' is req and 'data' is 120.

It should be urllib2.urlopen(req, None, 120).

--
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP post with urllib2

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 11:52 PM, cerr ron.egg...@gmail.com wrote:
 ./post.py
 Traceback (most recent call last):
   File ./post.py, line 13, in module
 response = urllib2.urlopen(req, 120)
   File /usr/lib/python2.7/urllib2.py, line 126, in urlopen
 return _opener.open(url, data, timeout)
   File /usr/lib/python2.7/urllib2.py, line 398, in open
 req = meth(req)
   File /usr/lib/python2.7/urllib2.py, line 1116, in do_request_
 'Content-length', '%d' % len(data))


 I don't get it, what's going on here?


You've given a traceback without the actual error. MRAB happened to
figure out the mistake just from what you posted, but in future, do
try to copy a bit more down :)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python HTTP POST

2013-07-18 Thread Sivaram Neelakantan
On Thu, Jul 18 2013,Joel Goldstick wrote:


[snipped 28 lines]


 Many people find urllib and urllib2 to be confusing.  There is a module
 called requests which makes this stuff a lot easier.  ymmv

 http://docs.python-requests.org/en/latest/

Yes, please use this instead of the url* ones, easier to work with and
tinker.  I just finished writing a small scraper using it.  The
documentation too is very good.


 sivaram
 -- 

-- 
http://mail.python.org/mailman/listinfo/python-list


Python HTTP POST

2013-07-17 Thread Matt Graves
I am going to be creating a python script that will make filling in information 
at my job easier.

I have all of the information I need... I guess I just need to see it in 
practice to fully grasp it.

How would I submit a python HTTP POST request to... for example, go to 
google.com, enter Pie into the search box and submit (Search)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python HTTP POST

2013-07-17 Thread John Gordon
In 00ec2f9b-fcae-428c-8932-163e653dd...@googlegroups.com Matt Graves 
tunacu...@gmail.com writes:

 How would I submit a python HTTP POST request to... for example, go to
 google.com, enter Pie into the search box and submit (Search)

Something like this:

import urllib
import urllib2

# the google form search input box is named 'q'
data = { 'q': 'Pie' }

response = urllib2.urlopen('http://google.com', urllib.urlencode(data))
print response.read()

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python HTTP POST

2013-07-17 Thread Joel Goldstick
On Wed, Jul 17, 2013 at 4:15 PM, John Gordon gor...@panix.com wrote:

 In 00ec2f9b-fcae-428c-8932-163e653dd...@googlegroups.com Matt Graves 
 tunacu...@gmail.com writes:

  How would I submit a python HTTP POST request to... for example, go to
  google.com, enter Pie into the search box and submit (Search)

 Something like this:

 import urllib
 import urllib2

 # the google form search input box is named 'q'
 data = { 'q': 'Pie' }

 response = urllib2.urlopen('http://google.com', urllib.urlencode(data))
 print response.read()

 --
 John Gordon   A is for Amy, who fell down the stairs
 gor...@panix.com  B is for Basil, assaulted by bears
 -- Edward Gorey, The Gashlycrumb Tinies

 --
 http://mail.python.org/mailman/listinfo/python-list



Many people find urllib and urllib2 to be confusing.  There is a module
called requests which makes this stuff a lot easier.  ymmv

http://docs.python-requests.org/en/latest/

-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python HTTP POST

2013-07-17 Thread alex23

On 18/07/2013 4:49 AM, Matt Graves wrote:

How would I submit a python HTTP POST request to... for example, go to google.com, enter 
Pie into the search box and submit (Search)


Other replies have suggested how you could do it by building the request 
yourself. Another approach is to interact directly with the form using 
mechanize:


http://wwwsearch.sourceforge.net/mechanize/

Unfortunately this doesn't appear to actually work with Google, as its 
robots.txt won't allow it. But if you're dealing with an intranet-based 
form in your organisation you should be fine.


--
http://mail.python.org/mailman/listinfo/python-list


[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-19 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

Committed, thanks!

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-18 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 24244a744d01 by Charles-François Natali in branch '2.6':
Issue #14001: CVE-2012-0845: xmlrpc: Fix an endless loop in SimpleXMLRPCServer
http://hg.python.org/cpython/rev/24244a744d01

New changeset 0c02f30b2538 by Charles-François Natali in branch '2.7':
Issue #14001: CVE-2012-0845: xmlrpc: Fix an endless loop in SimpleXMLRPCServer
http://hg.python.org/cpython/rev/0c02f30b2538

New changeset 4dd5a94fd3e3 by Charles-François Natali in branch '3.1':
Issue #14001: CVE-2012-0845: xmlrpc: Fix an endless loop in SimpleXMLRPCServer
http://hg.python.org/cpython/rev/4dd5a94fd3e3

New changeset cd67740ce653 by Charles-François Natali in branch '3.2':
Issue #14001: CVE-2012-0845: xmlrpc: Fix an endless loop in SimpleXMLRPCServer
http://hg.python.org/cpython/rev/cd67740ce653

New changeset 5756b295b6fb by Charles-François Natali in branch 'default':
Issue #14001: CVE-2012-0845: xmlrpc: Fix an endless loop in SimpleXMLRPCServer
http://hg.python.org/cpython/rev/5756b295b6fb

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-15 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

As a security issue, it applies to 2.6 and 3.1 as well.

--
versions: +Python 2.6, Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-15 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

The test fails on 2.6 and 2.7, because of a EPIPE, which is normal in
this case (well, at least expected):

test_partial_post (test.test_xmlrpc.SimpleServerTestCase) ...

Exception happened during processing of request from ('127.0.0.1', 47844)
Traceback (most recent call last):
  File /home/cf/python/cpython/Lib/SocketServer.py, line 283, in
_handle_request_noblock
self.process_request(request, client_address)
  File /home/cf/python/cpython/Lib/SocketServer.py, line 309, in
process_request
self.finish_request(request, client_address)
  File /home/cf/python/cpython/Lib/SocketServer.py, line 322, in
finish_request
self.RequestHandlerClass(request, client_address, self)
  File /home/cf/python/cpython/Lib/SocketServer.py, line 617, in __init__
self.handle()
  File /home/cf/python/cpython/Lib/BaseHTTPServer.py, line 329, in handle
self.handle_one_request()
  File /home/cf/python/cpython/Lib/BaseHTTPServer.py, line 323, in
handle_one_request
method()
  File /home/cf/python/cpython/Lib/SimpleXMLRPCServer.py, line 490, in do_POST
self.send_response(200)
  File /home/cf/python/cpython/Lib/BaseHTTPServer.py, line 384, in
send_response
self.send_header('Server', self.version_string())
  File /home/cf/python/cpython/Lib/BaseHTTPServer.py, line 390, in send_header
self.wfile.write(%s: %s\r\n % (keyword, value))
  File /home/cf/python/cpython/Lib/socket.py, line 318, in write
self.flush()
  File /home/cf/python/cpython/Lib/socket.py, line 297, in flush
self._sock.sendall(buffer(data, write_offset, buffer_size))
error: [Errno 32] Broken pipe


What should I do? Remove the test?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-14 Thread Jan Lieskovsky

Jan Lieskovsky ian...@seznam.cz added the comment:

The CVE identifier of CVE-2012-0845 has been assigned to this issue:
[3] http://www.openwall.com/lists/oss-security/2012/02/13/4

--
title: Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) 
by processing malformed XMLRPC / HTTP POST request - CVE-2012-0845 Python 
v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing 
malformed XMLRPC / HTTP POST request

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-14 Thread Senthil Kumaran

Changes by Senthil Kumaran sent...@uthcode.com:


--
nosy: +orsenthil

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-14 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
stage: needs patch - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-14 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

With test.
test_xmlrpc has a timeout detection code which is simply broken (and it's 
actually documented): I just removed it, so if the server loops, the test will 
block. I think it's acceptable since other tests behave in the same way, and 
those days we have faulthandler that can be used to pinpoint such 
deadlocks/loops easily. Also, I've noticed that people are more inclined to fix 
tests that block than mere failing tests :-)

--
Added file: http://bugs.python.org/file24522/xmlrpc_loop-1.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-14 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

The patch looks ok to me.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-13 Thread Jan Lieskovsky

New submission from Jan Lieskovsky ian...@seznam.cz:

A denial of service flaw was found in the way Simple XML-RPC Server module of 
Python processed client connections, that were closed prior the complete 
request body has been received. A remote attacker could use this flaw to cause 
Python Simple XML-RPC based server process to consume excessive amount of CPU.

Credit:
Issue reported by Daniel Callaghan

References:
[1] https://bugzilla.redhat.com/show_bug.cgi?id=789790

Steps to reproduce:
--
A) for v3.2.2 version:

1) start server:
cat s.py 
#!/usr/local/bin/python3

from xmlrpc.server import SimpleXMLRPCServer
server = SimpleXMLRPCServer(('127.0.0.1', 12345))
server.serve_forever()

2) # top

3) issue request from client:
echo -e 'POST /RPC2 HTTP/1.0\r\nContent-Length: 100\r\n\r\nlol bye' | nc 
localhost 12345

Return to 'top' screen and see, how CPU consumption on particular host quickly 
moves to 100%.

B) for v2.7.2 version:

1) start server:

cat s.py 
#!/usr/bin/python

from SimpleXMLRPCServer import SimpleXMLRPCServer

server = SimpleXMLRPCServer(('127.0.0.1', 12345))
server.serve_forever()

Steps 2) and 3) for v2.7.2 version are identical to
those for v3.2.2 version.

--
components: Library (Lib)
messages: 153267
nosy: iankko
priority: normal
severity: normal
status: open
title: Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) 
by processing malformed XMLRPC / HTTP POST request
type: security
versions: Python 2.7, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-13 Thread Ralf Schmitt

Changes by Ralf Schmitt python-b...@systemexit.de:


--
nosy: +schmir

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-13 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti, loewis
stage:  - needs patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-13 Thread Jan Lieskovsky

Jan Lieskovsky ian...@seznam.cz added the comment:

CVE request:
[2] http://www.openwall.com/lists/oss-security/2012/02/13/3

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-13 Thread Florent Xicluna

Changes by Florent Xicluna florent.xicl...@gmail.com:


--
components: +XML
nosy: +flox
versions: +Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-13 Thread Ross Lagerwall

Changes by Ross Lagerwall rosslagerw...@gmail.com:


--
nosy: +rosslagerwall

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-13 Thread Dave Malcolm

Changes by Dave Malcolm dmalc...@redhat.com:


--
nosy: +dmalcolm

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-13 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

SimpleXMLRPCRequestHandler.do_POST() is simply looping on EOF.
The patch attached fixes this (the server doesn't seem to generate an error in 
response to this partial request though).

--
keywords: +patch
nosy: +neologix
Added file: http://bugs.python.org/file24513/xmlrpc_loop.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14001] Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-13 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14001
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Http post and http get

2012-02-06 Thread n3d!m
Cookies work because I am able to login on website and GET other pages.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Google Chart API, HTTP POST request format.

2011-01-06 Thread Chris Rebert
On Wed, Jan 5, 2011 at 11:21 PM, Garland Fulton stacks...@gmail.com wrote:
 On Wed, Jan 5, 2011 at 7:26 PM, Tim Harig user...@ilthio.net wrote:

 On 2011-01-06, Slie stacks...@gmail.com wrote:
 [reformated to 80 columns per RFC 1855 guidelines]
  I have read several examples on python post requests but I'm not sure
  mine needs to be that complicated.

 From the HTML example on the page you posted:

    form action='https://chart.googleapis.com/chart' method='POST'
        input type=hidden name=cht value=lc  /
        input type=hidden name=chtt value=This is | my chart  /
        input type='hidden' name='chs' value='600x200' /
        input type=hidden name=chxt value=x,y /
        input type='hidden' name='chd' value='t:40,20,50,20,100'/
        input type=submit  /
    /form

 you can retreive the same chart from Python:

    Python 3.1.2 (r312:79147, Oct  9 2010, 00:16:06)
    [GCC 4.4.4] on linux2
    Type help, copyright, credits or license for more information.
     import urllib.request, urllib.parse
     params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my
     chart',
    ...         'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'})
     chart =
 urllib.request.urlopen('https://chart.googleapis.com/chart',
    ...         data = params).read()
     chartFile = open(chart.png, 'wb')
     chartFile.write(chart)
    10782
     chartFile.close()
 --
 http://mail.python.org/mailman/listinfo/python-list

 Hope this isn't to stupid,
 For the
 chart = urllib.request.urlopen('https://chart.googleapis.com/chart', data =
 params).read()
 Where would I find information on why and what the ).read() part does.

http://docs.python.org/py3k/library/urllib.request.html#urllib.request.urlopen
Specifically: This function returns a file-like object (representing
the stream of data received). Thus, .read() on the file-like object
returns the actual bytes obtained from the given URL.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Google Chart API, HTTP POST request format.

2011-01-06 Thread Tim Harig
On 2011-01-06, Chris Rebert c...@rebertia.com wrote:
 On Wed, Jan 5, 2011 at 11:21 PM, Garland Fulton stacks...@gmail.com wrote:
 On Wed, Jan 5, 2011 at 7:26 PM, Tim Harig user...@ilthio.net wrote:
    Python 3.1.2 (r312:79147, Oct  9 2010, 00:16:06)
    [GCC 4.4.4] on linux2
    Type help, copyright, credits or license for more information.
     import urllib.request, urllib.parse
     params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my
     chart',

Sorry I didn't notice this got accidently wrapped when I pasted it.
 params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my 
chart',

    ...         'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'})
     chart =
 urllib.request.urlopen('https://chart.googleapis.com/chart',
    ...         data = params).read()
     chartFile = open(chart.png, 'wb')
     chartFile.write(chart)
    10782
     chartFile.close()

 Hope this isn't to stupid,
 For the
 chart = urllib.request.urlopen('https://chart.googleapis.com/chart', data =
 params).read()
 Where would I find information on why and what the ).read() part does.

For some reason, posts from from this account don't seem to be making it
through the gateway to usenet so I am only seeing what Mr. Rebert has
replied to.  If you have asked anything else, I very well may have missed
it.

 http://docs.python.org/py3k/library/urllib.request.html#urllib.request.urlopen
 Specifically: This function returns a file-like object (representing
 the stream of data received). Thus, .read() on the file-like object
 returns the actual bytes obtained from the given URL.

Mr. Rebert already answed your question; but, I will expand on that a
little bit.  One of the great things about the Python language is that it
uses what is commonly known as duck typing.  That is anything object which
provides the same attributes as another object can be used as though it is
actually the second object.  It is kind of like an implicit form of
generics that doesn't require a template or an interface.

The Python standard library makes extensive use of duck typing for file
like objects.  Any object that provides the proper method attributes can be
given to functions that expect files even though the object is given might
not be the traditional concept of a file on the filesystem.  It might be a
stringIO object, a socket file object, or something new that you have
created that supports the required method attributes.

The semantics and documentation for file like objects have changed a
little for python2 vs. python3:

python2: http://docs.python.org/library/stdtypes.html#file-objects
python3: http://docs.python.org/py3k/library/io.html#io.IOBase

but they still basically work the same way.  Much of the Python 3
documentation still refers file objects.
-- 
http://mail.python.org/mailman/listinfo/python-list


Google Chart API, HTTP POST request format.

2011-01-05 Thread Slie

http://code.google.com/apis/chart/docs/post_requests.html

Google will return a chart in your browser from a URL that you have built. If 
your URL is bigger then 2K characters it will allow you to submit POST requests.

They gives examples of HTML, JavaScript, and PHP POST requests. Is there a way 
I can submit a request with Python? Or possibly submit the HTML, JavaScript or 
PHP using python?(That was a long shot thought). If I do that I would need to 
find out what to do with the .PNG it gives me.

Am I headed in the right direction, is the above paragraph about submitting an 
HTML form from my program even logical?

I have read several examples on python post requests but I'm not sure mine 
needs to be that complicated.


Thank You,
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Google Chart API, HTTP POST request format.

2011-01-05 Thread Tim Harig
On 2011-01-06, Slie stacks...@gmail.com wrote:
[reformated to 80 columns per RFC 1855 guidelines]
 I have read several examples on python post requests but I'm not sure
 mine needs to be that complicated.

From the HTML example on the page you posted:

form action='https://chart.googleapis.com/chart' method='POST'
input type=hidden name=cht value=lc  /
input type=hidden name=chtt value=This is | my chart  /
input type='hidden' name='chs' value='600x200' /
input type=hidden name=chxt value=x,y /
input type='hidden' name='chd' value='t:40,20,50,20,100'/
input type=submit  /
/form

you can retreive the same chart from Python:

Python 3.1.2 (r312:79147, Oct  9 2010, 00:16:06)
[GCC 4.4.4] on linux2
Type help, copyright, credits or license for more information.
 import urllib.request, urllib.parse
 params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my
 chart',
... 'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'})
 chart = urllib.request.urlopen('https://chart.googleapis.com/chart',
... data = params).read()
 chartFile = open(chart.png, 'wb')
 chartFile.write(chart)
10782
 chartFile.close()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Google Chart API, HTTP POST request format.

2011-01-05 Thread Chris Rebert
On Wed, Jan 5, 2011 at 7:36 PM, Slie stacks...@gmail.com wrote:

 http://code.google.com/apis/chart/docs/post_requests.html

 Google will return a chart in your browser from a URL that you have built. If 
 your URL is bigger then 2K characters it will allow you to submit POST 
 requests.

 They gives examples of HTML, JavaScript, and PHP POST requests. Is there a 
 way I can submit a request with Python? Or possibly submit the HTML, 
 JavaScript or PHP using python?(That was a long shot thought). If I do that I 
 would need to find out what to do with the .PNG it gives me.

 Am I headed in the right direction, is the above paragraph about submitting 
 an HTML form from my program even logical?

You should probably first try one of the existing Python wrappers for
Google's chart API and see if that meets your needs:
http://code.google.com/p/google-chartwrapper/
http://pygooglechart.slowchop.com/

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Google Chart API, HTTP POST request format.

2011-01-05 Thread Garland Fulton
I tried to use pygooglechart.py and I have been trying to get it set up
all day actually along with several other graphing API's.

I just found out that there is a problem with numpy and python 3.1 that is
why I moved from the API's. Should I change version just for
these library's?

Should I be learning Python on 3.1?

Awesome!


On Wed, Jan 5, 2011 at 7:52 PM, Chris Rebert c...@rebertia.com wrote:

 On Wed, Jan 5, 2011 at 7:36 PM, Slie stacks...@gmail.com wrote:
 
  http://code.google.com/apis/chart/docs/post_requests.html
 
  Google will return a chart in your browser from a URL that you have
 built. If your URL is bigger then 2K characters it will allow you to submit
 POST requests.
 
  They gives examples of HTML, JavaScript, and PHP POST requests. Is there
 a way I can submit a request with Python? Or possibly submit the HTML,
 JavaScript or PHP using python?(That was a long shot thought). If I do that
 I would need to find out what to do with the .PNG it gives me.
 
  Am I headed in the right direction, is the above paragraph about
 submitting an HTML form from my program even logical?

 You should probably first try one of the existing Python wrappers for
 Google's chart API and see if that meets your needs:
 http://code.google.com/p/google-chartwrapper/
 http://pygooglechart.slowchop.com/

 Cheers,
 Chris
 --
 http://blog.rebertia.com

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Google Chart API, HTTP POST request format.

2011-01-05 Thread Garland Fulton
Thank you for showing me the POST request, I will defiantly learn a lot from
that.

On Wed, Jan 5, 2011 at 7:26 PM, Tim Harig user...@ilthio.net wrote:

 On 2011-01-06, Slie stacks...@gmail.com wrote:
 [reformated to 80 columns per RFC 1855 guidelines]
  I have read several examples on python post requests but I'm not sure
  mine needs to be that complicated.

 From the HTML example on the page you posted:

form action='https://chart.googleapis.com/chart' method='POST'
input type=hidden name=cht value=lc  /
input type=hidden name=chtt value=This is | my chart  /
input type='hidden' name='chs' value='600x200' /
input type=hidden name=chxt value=x,y /
input type='hidden' name='chd' value='t:40,20,50,20,100'/
input type=submit  /
/form

 you can retreive the same chart from Python:

Python 3.1.2 (r312:79147, Oct  9 2010, 00:16:06)
[GCC 4.4.4] on linux2
Type help, copyright, credits or license for more information.
 import urllib.request, urllib.parse
 params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my
 chart',
... 'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'})
 chart = urllib.request.urlopen('https://chart.googleapis.com/chart
 ',
... data = params).read()
 chartFile = open(chart.png, 'wb')
 chartFile.write(chart)
10782
 chartFile.close()
 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Google Chart API, HTTP POST request format.

2011-01-05 Thread Corey Richardson
On 01/06/2011 12:16 AM, Garland Fulton wrote:
 I tried to use pygooglechart.py and I have been trying to get it set
 up all day actually along with several other graphing API's.
 
 I just found out that there is a problem with numpy and python 3.1 that
 is why I moved from the API's. Should I change version just for
 these library's?
 
 Should I be learning Python on 3.1?
 
 Awesome!
 
 [snip]

I swapped from 3 to 2.6 a while back, better support for modules, and
not really losing much in the way of features.

~Corey Richardson

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Google Chart API, HTTP POST request format.

2011-01-05 Thread Chris Rebert
 On Wed, Jan 5, 2011 at 7:52 PM, Chris Rebert c...@rebertia.com wrote:
 On Wed, Jan 5, 2011 at 7:36 PM, Slie stacks...@gmail.com wrote:
 
  http://code.google.com/apis/chart/docs/post_requests.html
 
  Google will return a chart in your browser from a URL that you have
  built. If your URL is bigger then 2K characters it will allow you to submit
  POST requests.
 
  They gives examples of HTML, JavaScript, and PHP POST requests. Is there
  a way I can submit a request with Python? Or possibly submit the HTML,
  JavaScript or PHP using python?(That was a long shot thought). If I do that
  I would need to find out what to do with the .PNG it gives me.
 
  Am I headed in the right direction, is the above paragraph about
  submitting an HTML form from my program even logical?

 You should probably first try one of the existing Python wrappers for
 Google's chart API and see if that meets your needs:
 http://code.google.com/p/google-chartwrapper/
 http://pygooglechart.slowchop.com/

On Wed, Jan 5, 2011 at 9:16 PM, Garland Fulton stacks...@gmail.com wrote:
 I tried to use pygooglechart.py and I have been trying to get it set up
 all day actually along with several other graphing API's.
 I just found out that there is a problem with numpy and python 3.1 that is
 why I moved from the API's. Should I change version just for
 these library's?
 Should I be learning Python on 3.1?

Most third-party libraries have yet to be ported to Python 3.1 (with a
few notable exceptions). If you actually want to write
non-(toy/demo/trivial) programs, you should probably use Python 2.x.
Python 3.1 is fine for learning the basics of the language; once
you've done that, learning the Python 2.x differences and wart
workarounds is not hard.

(Also, in the future, please don't top-post.)

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Google Chart API, HTTP POST request format.

2011-01-05 Thread Garland Fulton
On Wed, Jan 5, 2011 at 7:52 PM, Chris Rebert c...@rebertia.com wrote:

 On Wed, Jan 5, 2011 at 7:36 PM, Slie stacks...@gmail.com wrote:
 
  http://code.google.com/apis/chart/docs/post_requests.html
 
  Google will return a chart in your browser from a URL that you have
 built. If your URL is bigger then 2K characters it will allow you to submit
 POST requests.
 
  They gives examples of HTML, JavaScript, and PHP POST requests. Is there
 a way I can submit a request with Python? Or possibly submit the HTML,
 JavaScript or PHP using python?(That was a long shot thought). If I do that
 I would need to find out what to do with the .PNG it gives me.
 
  Am I headed in the right direction, is the above paragraph about
 submitting an HTML form from my program even logical?

 You should probably first try one of the existing Python wrappers for
 Google's chart API and see if that meets your needs:
 http://code.google.com/p/google-chartwrapper/
 http://pygooglechart.slowchop.com/

 Cheers,
 Chris
 --
 http://blog.rebertia.com

Google Chart Wrapper is compatible with 3.1 and i have been looking all day
for something like this. Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Google Chart API, HTTP POST request format.

2011-01-05 Thread Garland Fulton
On Wed, Jan 5, 2011 at 7:26 PM, Tim Harig user...@ilthio.net wrote:

 On 2011-01-06, Slie stacks...@gmail.com wrote:
 [reformated to 80 columns per RFC 1855 guidelines]
  I have read several examples on python post requests but I'm not sure
  mine needs to be that complicated.

 From the HTML example on the page you posted:

form action='https://chart.googleapis.com/chart' method='POST'
input type=hidden name=cht value=lc  /
input type=hidden name=chtt value=This is | my chart  /
input type='hidden' name='chs' value='600x200' /
input type=hidden name=chxt value=x,y /
input type='hidden' name='chd' value='t:40,20,50,20,100'/
input type=submit  /
/form

 you can retreive the same chart from Python:

Python 3.1.2 (r312:79147, Oct  9 2010, 00:16:06)
[GCC 4.4.4] on linux2
Type help, copyright, credits or license for more information.
 import urllib.request, urllib.parse
 params = urllib.parse.urlencode({'cht':'lc', 'chtt':'This is | my
 chart',
... 'chs':'600x200', 'chxt':'x,y', 'chd':'t:40,20,50,20,100'})
 chart = urllib.request.urlopen('https://chart.googleapis.com/chart
 ',
... data = params).read()
 chartFile = open(chart.png, 'wb')
 chartFile.write(chart)
10782
 chartFile.close()
 --
 http://mail.python.org/mailman/listinfo/python-list


Hope this isn't to stupid,

For the
chart = urllib.request.urlopen('https://chart.googleapis.com/chart', data =
params).read()

Where would I find information on why and what the ).read() part does.

Thank you,
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: http post

2010-05-28 Thread christian schulze
On 28 Mai, 16:47, yqyq22 yqy...@hotmail.com wrote:
 Hy, i would like to create a little script to reproduce this one
 below:
 Do you have suggestion?

 POST /folder/path/upload.exe?/dir HTTP/1.1
 Host: 192.168.100.1:8080
 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
 1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
 *;q=0.8
 Accept-Language: en-us,en;q=0.5
 Accept-Encoding: gzip,deflate
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
 Keep-Alive: 115
 Proxy-Connection: keep-alive
 Referer:http://192.168.1.100:8080/dir1
 Content-Type: multipart/form-data;
 boundary=---7075104567331
 Content-Length: 539
 Connection: close

 -7075104567331
 Content-Disposition: form-data; name=F1; filename=file.txt
 Content-Type: application/octet-stream

 -7075104567331
 Content-Disposition: form-data; name=p4

 -7075104567331--

 THANKS A LOT

Just send it via a socket? Or use urllib, afair you can send custom
HTTP headers.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: http post

2010-05-28 Thread yqyq22
On May 28, 5:17 pm, christian schulze xcr...@googlemail.com wrote:
 On 28 Mai, 16:47, yqyq22 yqy...@hotmail.com wrote:





  Hy, i would like to create a little script to reproduce this one
  below:
  Do you have suggestion?

  POST /folder/path/upload.exe?/dir HTTP/1.1
  Host: 192.168.100.1:8080
  User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
  1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
  *;q=0.8
  Accept-Language: en-us,en;q=0.5
  Accept-Encoding: gzip,deflate
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
  Keep-Alive: 115
  Proxy-Connection: keep-alive
  Referer:http://192.168.1.100:8080/dir1
  Content-Type: multipart/form-data;
  boundary=---7075104567331
  Content-Length: 539
  Connection: close

  -7075104567331
  Content-Disposition: form-data; name=F1; filename=file.txt
  Content-Type: application/octet-stream

  -7075104567331
  Content-Disposition: form-data; name=p4

  -7075104567331--

  THANKS A LOT

 Just send it via a socket? Or use urllib, afair you can send custom
 HTTP headers.- Hide quoted text -

 - Show quoted text -

If i understood right i would use only socket.. is it possible?
thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: http post

2010-05-28 Thread christian schulze
On 28 Mai, 17:20, yqyq22 yqy...@hotmail.com wrote:
 On May 28, 5:17 pm, christian schulze xcr...@googlemail.com wrote:



  On 28 Mai, 16:47, yqyq22 yqy...@hotmail.com wrote:

   Hy, i would like to create a little script to reproduce this one
   below:
   Do you have suggestion?

   POST /folder/path/upload.exe?/dir HTTP/1.1
   Host: 192.168.100.1:8080
   User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
   1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
   Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
   *;q=0.8
   Accept-Language: en-us,en;q=0.5
   Accept-Encoding: gzip,deflate
   Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
   Keep-Alive: 115
   Proxy-Connection: keep-alive
   Referer:http://192.168.1.100:8080/dir1
   Content-Type: multipart/form-data;
   boundary=---7075104567331
   Content-Length: 539
   Connection: close

   -7075104567331
   Content-Disposition: form-data; name=F1; filename=file.txt
   Content-Type: application/octet-stream

   -7075104567331
   Content-Disposition: form-data; name=p4

   -7075104567331--

   THANKS A LOT

  Just send it via a socket? Or use urllib, afair you can send custom
  HTTP headers.- Hide quoted text -

  - Show quoted text -

 If i understood right i would use only socket.. is it possible?
 thanks

Yeah i think so, but i am not quite sure. Just test it :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: http post

2010-05-28 Thread yqyq22
On May 28, 5:24 pm, christian schulze xcr...@googlemail.com wrote:
 On 28 Mai, 17:20, yqyq22 yqy...@hotmail.com wrote:





  On May 28, 5:17 pm, christian schulze xcr...@googlemail.com wrote:

   On 28 Mai, 16:47, yqyq22 yqy...@hotmail.com wrote:

Hy, i would like to create a little script to reproduce this one
below:
Do you have suggestion?

POST /folder/path/upload.exe?/dir HTTP/1.1
Host: 192.168.100.1:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Proxy-Connection: keep-alive
Referer:http://192.168.1.100:8080/dir1
Content-Type: multipart/form-data;
boundary=---7075104567331
Content-Length: 539
Connection: close

-7075104567331
Content-Disposition: form-data; name=F1; filename=file.txt
Content-Type: application/octet-stream

-7075104567331
Content-Disposition: form-data; name=p4

-7075104567331--

THANKS A LOT

   Just send it via a socket? Or use urllib, afair you can send custom
   HTTP headers.- Hide quoted text -

   - Show quoted text -

  If i understood right i would use only socket.. is it possible?
  thanks

 Yeah i think so, but i am not quite sure. Just test it :)- Hide quoted text -

 - Show quoted text -

Do u have an example/link closed to my need? thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP Post Request

2010-05-12 Thread kak...@gmail.com
On May 12, 6:13 am, Kushal Kumaran kushal.kumaran+pyt...@gmail.com
wrote:
 On Tue, May 11, 2010 at 3:59 PM, kak...@gmail.com kak...@gmail.com wrote:
  On May 11, 10:56 am, kak...@gmail.com kak...@gmail.com wrote:
  On May 11, 5:06 am, Kushal Kumaran kushal.kumaran+pyt...@gmail.com
  wrote:

   On Mon, May 10, 2010 at 8:26 PM, kak...@gmail.com kak...@gmail.com 
   wrote:
On May 10, 10:22 am, Kushal Kumaran kushal.kumaran+pyt...@gmail.com
wrote:
On Mon, May 10, 2010 at 7:30 PM, kak...@gmail.com kak...@gmail.com 
wrote:
 Hi to all, i want to ask you a question, concerning the best way to 
 do
 the following as a POST request:
 There is server-servlet that accepts xml commands
 It had the following HTTP request headers:

            Host: somehost.com
            User-Agent: Jakarta Commons-HttpClient
            Content-Type: text/xml
            Content-Length: 415

 and the following request body (reformatted here for clarity):

            ?xml version='1.0'?
            methodCall
              methodNamesearch/methodName
            /methodCall
 How can i send the above to the Listener Servlet?
 Thanks in advance

Use the xmlrpclib module.

OK, sending headers with xmlrpclib,
but how do i send the XML message?

   Your XML message is an XML RPC message.  You will use xmlrpclib like 
   this:

   server_proxy = xmlrpclib.ServerProxy(('somehost.com', 80))
   result = server_proxy.search()

   The call to server_proxy.search will result in an actual XML RPC
   message being sent.

   Read up on the xmlrpclib documentation 
   here:http://docs.python.org/library/xmlrpclib.html, and the XMLRPC spec
   here:http://www.xmlrpc.com/spec

  Ok I got it!
  Thank you!!!

  A.K

  Apparently the server i'm trying to connect accepts only POST
  connections. So xmlrpclib is useless.
  I think I need the httplib library module.

  Any hints?

 I don't understand.  xmlrpclib sends POST requests only.  Are you
 getting an exception?  If so, please post the entire stack trace.

 If you want to send the data by hand, use the httplib module.  you
 can pass your XML to the HTTPConnection.request method as the body
 argument.

 --
 regards,
 kushal

Ok i found it. I sent the xml by hand with httplib module.
i use the last example of http://docs.python.org/library/httplib.html
and it worked.
Thank you very much for your response.

A.K.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP Post Request

2010-05-11 Thread kak...@gmail.com
On May 11, 5:06 am, Kushal Kumaran kushal.kumaran+pyt...@gmail.com
wrote:
 On Mon, May 10, 2010 at 8:26 PM, kak...@gmail.com kak...@gmail.com wrote:
  On May 10, 10:22 am, Kushal Kumaran kushal.kumaran+pyt...@gmail.com
  wrote:
  On Mon, May 10, 2010 at 7:30 PM, kak...@gmail.com kak...@gmail.com wrote:
   Hi to all, i want to ask you a question, concerning the best way to do
   the following as a POST request:
   There is server-servlet that accepts xml commands
   It had the following HTTP request headers:

              Host: somehost.com
              User-Agent: Jakarta Commons-HttpClient
              Content-Type: text/xml
              Content-Length: 415

   and the following request body (reformatted here for clarity):

              ?xml version='1.0'?
              methodCall
                methodNamesearch/methodName
              /methodCall
   How can i send the above to the Listener Servlet?
   Thanks in advance

  Use the xmlrpclib module.

  OK, sending headers with xmlrpclib,
  but how do i send the XML message?

 Your XML message is an XML RPC message.  You will use xmlrpclib like this:

 server_proxy = xmlrpclib.ServerProxy(('somehost.com', 80))
 result = server_proxy.search()

 The call to server_proxy.search will result in an actual XML RPC
 message being sent.

 Read up on the xmlrpclib documentation 
 here:http://docs.python.org/library/xmlrpclib.html, and the XMLRPC spec
 here:http://www.xmlrpc.com/spec

 --
 regards,
 kushal

Ok I got it!
Thank you!!!

A.K
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP Post Request

2010-05-11 Thread kak...@gmail.com
On May 11, 10:56 am, kak...@gmail.com kak...@gmail.com wrote:
 On May 11, 5:06 am, Kushal Kumaran kushal.kumaran+pyt...@gmail.com
 wrote:



  On Mon, May 10, 2010 at 8:26 PM, kak...@gmail.com kak...@gmail.com wrote:
   On May 10, 10:22 am, Kushal Kumaran kushal.kumaran+pyt...@gmail.com
   wrote:
   On Mon, May 10, 2010 at 7:30 PM, kak...@gmail.com kak...@gmail.com 
   wrote:
Hi to all, i want to ask you a question, concerning the best way to do
the following as a POST request:
There is server-servlet that accepts xml commands
It had the following HTTP request headers:

           Host: somehost.com
           User-Agent: Jakarta Commons-HttpClient
           Content-Type: text/xml
           Content-Length: 415

and the following request body (reformatted here for clarity):

           ?xml version='1.0'?
           methodCall
             methodNamesearch/methodName
           /methodCall
How can i send the above to the Listener Servlet?
Thanks in advance

   Use the xmlrpclib module.

   OK, sending headers with xmlrpclib,
   but how do i send the XML message?

  Your XML message is an XML RPC message.  You will use xmlrpclib like this:

  server_proxy = xmlrpclib.ServerProxy(('somehost.com', 80))
  result = server_proxy.search()

  The call to server_proxy.search will result in an actual XML RPC
  message being sent.

  Read up on the xmlrpclib documentation 
  here:http://docs.python.org/library/xmlrpclib.html, and the XMLRPC spec
  here:http://www.xmlrpc.com/spec

  --
  regards,
  kushal

 Ok I got it!
 Thank you!!!

 A.K

Apparently the server i'm trying to connect accepts only POST
connections. So xmlrpclib is useless.
I think I need the httplib library module.

Any hints?

A.K.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP Post Request

2010-05-11 Thread Kushal Kumaran
On Tue, May 11, 2010 at 3:59 PM, kak...@gmail.com kak...@gmail.com wrote:
 On May 11, 10:56 am, kak...@gmail.com kak...@gmail.com wrote:
 On May 11, 5:06 am, Kushal Kumaran kushal.kumaran+pyt...@gmail.com
 wrote:



  On Mon, May 10, 2010 at 8:26 PM, kak...@gmail.com kak...@gmail.com wrote:
   On May 10, 10:22 am, Kushal Kumaran kushal.kumaran+pyt...@gmail.com
   wrote:
   On Mon, May 10, 2010 at 7:30 PM, kak...@gmail.com kak...@gmail.com 
   wrote:
Hi to all, i want to ask you a question, concerning the best way to do
the following as a POST request:
There is server-servlet that accepts xml commands
It had the following HTTP request headers:

           Host: somehost.com
           User-Agent: Jakarta Commons-HttpClient
           Content-Type: text/xml
           Content-Length: 415

and the following request body (reformatted here for clarity):

           ?xml version='1.0'?
           methodCall
             methodNamesearch/methodName
           /methodCall
How can i send the above to the Listener Servlet?
Thanks in advance

   Use the xmlrpclib module.

   OK, sending headers with xmlrpclib,
   but how do i send the XML message?

  Your XML message is an XML RPC message.  You will use xmlrpclib like this:

  server_proxy = xmlrpclib.ServerProxy(('somehost.com', 80))
  result = server_proxy.search()

  The call to server_proxy.search will result in an actual XML RPC
  message being sent.

  Read up on the xmlrpclib documentation 
  here:http://docs.python.org/library/xmlrpclib.html, and the XMLRPC spec
  here:http://www.xmlrpc.com/spec


 Ok I got it!
 Thank you!!!

 A.K

 Apparently the server i'm trying to connect accepts only POST
 connections. So xmlrpclib is useless.
 I think I need the httplib library module.

 Any hints?


I don't understand.  xmlrpclib sends POST requests only.  Are you
getting an exception?  If so, please post the entire stack trace.

If you want to send the data by hand, use the httplib module.  you
can pass your XML to the HTTPConnection.request method as the body
argument.

-- 
regards,
kushal
-- 
http://mail.python.org/mailman/listinfo/python-list


HTTP Post Request

2010-05-10 Thread kak...@gmail.com
Hi to all, i want to ask you a question, concerning the best way to do
the following as a POST request:
There is server-servlet that accepts xml commands
It had the following HTTP request headers:

Host: somehost.com
User-Agent: Jakarta Commons-HttpClient
Content-Type: text/xml
Content-Length: 415

and the following request body (reformatted here for clarity):

?xml version='1.0'?
methodCall
  methodNamesearch/methodName
/methodCall
How can i send the above to the Listener Servlet?
Thanks in advance
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP Post Request

2010-05-10 Thread Kushal Kumaran
On Mon, May 10, 2010 at 7:30 PM, kak...@gmail.com kak...@gmail.com wrote:
 Hi to all, i want to ask you a question, concerning the best way to do
 the following as a POST request:
 There is server-servlet that accepts xml commands
 It had the following HTTP request headers:

            Host: somehost.com
            User-Agent: Jakarta Commons-HttpClient
            Content-Type: text/xml
            Content-Length: 415

 and the following request body (reformatted here for clarity):

            ?xml version='1.0'?
            methodCall
              methodNamesearch/methodName
            /methodCall
 How can i send the above to the Listener Servlet?
 Thanks in advance

Use the xmlrpclib module.

-- 
regards,
kushal
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP Post Request

2010-05-10 Thread kak...@gmail.com
On May 10, 10:22 am, Kushal Kumaran kushal.kumaran+pyt...@gmail.com
wrote:
 On Mon, May 10, 2010 at 7:30 PM, kak...@gmail.com kak...@gmail.com wrote:
  Hi to all, i want to ask you a question, concerning the best way to do
  the following as a POST request:
  There is server-servlet that accepts xml commands
  It had the following HTTP request headers:

             Host: somehost.com
             User-Agent: Jakarta Commons-HttpClient
             Content-Type: text/xml
             Content-Length: 415

  and the following request body (reformatted here for clarity):

             ?xml version='1.0'?
             methodCall
               methodNamesearch/methodName
             /methodCall
  How can i send the above to the Listener Servlet?
  Thanks in advance

 Use the xmlrpclib module.

 --
 regards,
 kushal

OK, sending headers with xmlrpclib,
but how do i send the XML message?

Thanks
A.K.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP Post Request

2010-05-10 Thread Kushal Kumaran
On Mon, May 10, 2010 at 8:26 PM, kak...@gmail.com kak...@gmail.com wrote:
 On May 10, 10:22 am, Kushal Kumaran kushal.kumaran+pyt...@gmail.com
 wrote:
 On Mon, May 10, 2010 at 7:30 PM, kak...@gmail.com kak...@gmail.com wrote:
  Hi to all, i want to ask you a question, concerning the best way to do
  the following as a POST request:
  There is server-servlet that accepts xml commands
  It had the following HTTP request headers:

             Host: somehost.com
             User-Agent: Jakarta Commons-HttpClient
             Content-Type: text/xml
             Content-Length: 415

  and the following request body (reformatted here for clarity):

             ?xml version='1.0'?
             methodCall
               methodNamesearch/methodName
             /methodCall
  How can i send the above to the Listener Servlet?
  Thanks in advance

 Use the xmlrpclib module.


 OK, sending headers with xmlrpclib,
 but how do i send the XML message?


Your XML message is an XML RPC message.  You will use xmlrpclib like this:

server_proxy = xmlrpclib.ServerProxy(('somehost.com', 80))
result = server_proxy.search()

The call to server_proxy.search will result in an actual XML RPC
message being sent.

Read up on the xmlrpclib documentation here:
http://docs.python.org/library/xmlrpclib.html, and the XMLRPC spec
here: http://www.xmlrpc.com/spec

-- 
regards,
kushal
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python and http POST

2010-02-13 Thread galileo228
Thank you all for your responses, and Javier thank you for your longer
response. I've just downloaded mechanize and beautifulsoup and will
start to play around.

From a pure learning standpoint, however, I'd really like to learn how
to use the python post method (without mechanize) to go to a webpage,
fill in a form, click 'submit', follow the redirect to the results
page, and download content.

For example, if I go to google.com, use firebug and click on the
search bar, the following HTML is highlighted:

input value= title=Google Search class=lst size=55 name=q
maxlength=2048
onblur=googleamp;amp;google.fadeamp;amp;google.fade()
autocomplete=off

So if I were to use the 'post' method, how can I tell from the code
above what the ID of the searchbar is? Is it 'value', 'name', or
neither?

Assuming that the ID is 'name', then to search google for the term
'olypmics' would the proper code be:

import httplib2
import urllib
data = {'q':'olympics'}
body = urllib.urlencode(data)
h = httplib2.Http()
resp, content = h.request(http://www.google.com;, method=POST,
body=body)
print content;

Does content return the content of the 'search results' page? And if
not, how do I tell python to do that?
Finally, must I transmit headers, or are they optional?

Thanks all for your continued help!

Matt


On Feb 12, 2:59 am, Javier Collado javier.coll...@gmail.com wrote:
 Hello,

 I haven't used httplib2, but you can certainly use any other
 alternative to send HTTP requests:
 - urllib/urllib2
 - mechanize

 With regard to how do you find the form you're looking for, you may:
 - create the HTTP request on your own with urllib2. To find out what
 variables do you need to post, you can use tamperdata Firefox addon as
 suggested (I haven't used that one) or httpfox (I have and it works
 great).
 - use mechanize to locate the form for you, fill the data in and click
 on the submit button.

 Additionally, you may wan to scrape some data that may be useful for
 your requests. For that BeautifulSoup is good solution (with some
 Firebug help to visually locate what you're looking for).

 Best regards,
     Javier

 P.S. Some examples 
 here:http://www.packtpub.com/article/web-scraping-with-pythonhttp://www.packtpub.com/article/web-scraping-with-python-part-2

 2010/2/11 galileo228 mattbar...@gmail.com:

  Hey All,

  Been teaching myself Python for a few weeks, and am trying to write a
  program that will go to a url, enter a string in one of the search
  fields, submit the search, and return the contents of the search
  result.

  I'm using httplib2.

  My two particular questions:

  1) When I set my 'body' var, (i.e. 'body = {'query':'search_term'}),
  how do I know what the particular key should be? In other words, how
  do I tell python which form on the web page I'm visiting I'd like to
  fill in? Do I simply go to the webpage itself and look at the html
  source? But if that's the case, which tag tells me the name of the
  key?

  2) Even once python fills in the form properly, how can I tell it to
  'submit' the search?

  Thanks all!

  Matt
  --
 http://mail.python.org/mailman/listinfo/python-list



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python and http POST

2010-02-13 Thread galileo228
Thank you all for your responses, and Javier thank you for your longer
response. I've just downloaded mechanize and beautifulsoup and will
start to play around.

From a pure learning standpoint, however, I'd really like to learn how
to use the python post method (without mechanize) to go to a webpage,
fill in a form, click 'submit', follow the redirect to the results
page, and download content.

For example, if I go to google.com, use firebug and click on the
search bar, the following HTML is highlighted:

input value= title=Google Search class=lst size=55 name=q
maxlength=2048
onblur=googleamp;amp;google.fadeamp;amp;google.fade()
autocomplete=off

So if I were to use the 'post' method, how can I tell from the code
above what the ID of the searchbar is? Is it 'value', 'name', or
neither?

Assuming that the ID is 'name', then to search google for the term
'olypmics' would the proper code be:

import httplib2
import urllib
data = {'q':'olympics'}
body = urllib.urlencode(data)
h = httplib2.Http()
resp, content = h.request(http://www.google.com;, method=POST,
body=body)
print content;

Does content return the content of the 'search results' page? And if
not, how do I tell python to do that?
Finally, must I transmit headers, or are they optional?

Thanks all for your continued help!

Matt


On Feb 12, 2:59 am, Javier Collado javier.coll...@gmail.com wrote:
 Hello,

 I haven't used httplib2, but you can certainly use any other
 alternative to send HTTP requests:
 - urllib/urllib2
 - mechanize

 With regard to how do you find the form you're looking for, you may:
 - create the HTTP request on your own with urllib2. To find out what
 variables do you need to post, you can use tamperdata Firefox addon as
 suggested (I haven't used that one) or httpfox (I have and it works
 great).
 - use mechanize to locate the form for you, fill the data in and click
 on the submit button.

 Additionally, you may wan to scrape some data that may be useful for
 your requests. For that BeautifulSoup is good solution (with some
 Firebug help to visually locate what you're looking for).

 Best regards,
     Javier

 P.S. Some examples 
 here:http://www.packtpub.com/article/web-scraping-with-pythonhttp://www.packtpub.com/article/web-scraping-with-python-part-2

 2010/2/11 galileo228 mattbar...@gmail.com:

  Hey All,

  Been teaching myself Python for a few weeks, and am trying to write a
  program that will go to a url, enter a string in one of the search
  fields, submit the search, and return the contents of the search
  result.

  I'm using httplib2.

  My two particular questions:

  1) When I set my 'body' var, (i.e. 'body = {'query':'search_term'}),
  how do I know what the particular key should be? In other words, how
  do I tell python which form on the web page I'm visiting I'd like to
  fill in? Do I simply go to the webpage itself and look at the html
  source? But if that's the case, which tag tells me the name of the
  key?

  2) Even once python fills in the form properly, how can I tell it to
  'submit' the search?

  Thanks all!

  Matt
  --
 http://mail.python.org/mailman/listinfo/python-list



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python and http POST

2010-02-13 Thread galileo228
Thank you all for your responses, and Javier thank you for your longer
response. I've just downloaded mechanize and beautifulsoup and will
start to play around.

From a pure learning standpoint, however, I'd really like to learn how
to use the python post method (without mechanize) to go to a webpage,
fill in a form, click 'submit', follow the redirect to the results
page, and download content.

For example, if I go to google.com, use firebug and click on the
search bar, the following HTML is highlighted:

input value= title=Google Search class=lst size=55 name=q
maxlength=2048
onblur=googleamp;amp;google.fadeamp;amp;google.fade()
autocomplete=off

So if I were to use the 'post' method, how can I tell from the code
above what the ID of the searchbar is? Is it 'value', 'name', or
neither?

Assuming that the ID is 'name', then to search google for the term
'olypmics' would the proper code be:

import httplib2
import urllib
data = {'q':'olympics'}
body = urllib.urlencode(data)
h = httplib2.Http()
resp, content = h.request(http://www.google.com;, method=POST,
body=body)
print content;

Does content return the content of the 'search results' page? And if
not, how do I tell python to do that?
Finally, must I transmit headers, or are they optional?

Thanks all for your continued help!

Matt


On Feb 12, 2:59 am, Javier Collado javier.coll...@gmail.com wrote:
 Hello,

 I haven't used httplib2, but you can certainly use any other
 alternative to send HTTP requests:
 - urllib/urllib2
 - mechanize

 With regard to how do you find the form you're looking for, you may:
 - create the HTTP request on your own with urllib2. To find out what
 variables do you need to post, you can use tamperdata Firefox addon as
 suggested (I haven't used that one) or httpfox (I have and it works
 great).
 - use mechanize to locate the form for you, fill the data in and click
 on the submit button.

 Additionally, you may wan to scrape some data that may be useful for
 your requests. For that BeautifulSoup is good solution (with some
 Firebug help to visually locate what you're looking for).

 Best regards,
     Javier

 P.S. Some examples 
 here:http://www.packtpub.com/article/web-scraping-with-pythonhttp://www.packtpub.com/article/web-scraping-with-python-part-2

 2010/2/11 galileo228 mattbar...@gmail.com:

  Hey All,

  Been teaching myself Python for a few weeks, and am trying to write a
  program that will go to a url, enter a string in one of the search
  fields, submit the search, and return the contents of the search
  result.

  I'm using httplib2.

  My two particular questions:

  1) When I set my 'body' var, (i.e. 'body = {'query':'search_term'}),
  how do I know what the particular key should be? In other words, how
  do I tell python which form on the web page I'm visiting I'd like to
  fill in? Do I simply go to the webpage itself and look at the html
  source? But if that's the case, which tag tells me the name of the
  key?

  2) Even once python fills in the form properly, how can I tell it to
  'submit' the search?

  Thanks all!

  Matt
  --
 http://mail.python.org/mailman/listinfo/python-list



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python and http POST

2010-02-12 Thread Javier Collado
Hello,

I haven't used httplib2, but you can certainly use any other
alternative to send HTTP requests:
- urllib/urllib2
- mechanize

With regard to how do you find the form you're looking for, you may:
- create the HTTP request on your own with urllib2. To find out what
variables do you need to post, you can use tamperdata Firefox addon as
suggested (I haven't used that one) or httpfox (I have and it works
great).
- use mechanize to locate the form for you, fill the data in and click
on the submit button.

Additionally, you may wan to scrape some data that may be useful for
your requests. For that BeautifulSoup is good solution (with some
Firebug help to visually locate what you're looking for).

Best regards,
Javier

P.S. Some examples here:
http://www.packtpub.com/article/web-scraping-with-python
http://www.packtpub.com/article/web-scraping-with-python-part-2

2010/2/11 galileo228 mattbar...@gmail.com:
 Hey All,

 Been teaching myself Python for a few weeks, and am trying to write a
 program that will go to a url, enter a string in one of the search
 fields, submit the search, and return the contents of the search
 result.

 I'm using httplib2.

 My two particular questions:

 1) When I set my 'body' var, (i.e. 'body = {'query':'search_term'}),
 how do I know what the particular key should be? In other words, how
 do I tell python which form on the web page I'm visiting I'd like to
 fill in? Do I simply go to the webpage itself and look at the html
 source? But if that's the case, which tag tells me the name of the
 key?

 2) Even once python fills in the form properly, how can I tell it to
 'submit' the search?

 Thanks all!

 Matt
 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


python and http POST

2010-02-11 Thread galileo228
Hey All,

Been teaching myself Python for a few weeks, and am trying to write a
program that will go to a url, enter a string in one of the search
fields, submit the search, and return the contents of the search
result.

I'm using httplib2.

My two particular questions:

1) When I set my 'body' var, (i.e. 'body = {'query':'search_term'}),
how do I know what the particular key should be? In other words, how
do I tell python which form on the web page I'm visiting I'd like to
fill in? Do I simply go to the webpage itself and look at the html
source? But if that's the case, which tag tells me the name of the
key?

2) Even once python fills in the form properly, how can I tell it to
'submit' the search?

Thanks all!

Matt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python and http POST

2010-02-11 Thread Ken Seehart
Use tamperdata to view and modify HTTP/HTTPS headers and post 
parameters... 


https://addons.mozilla.org/en-US/firefox/addon/966

Enjoy,
Ken

galileo228 wrote:

Hey All,

Been teaching myself Python for a few weeks, and am trying to write a
program that will go to a url, enter a string in one of the search
fields, submit the search, and return the contents of the search
result.

I'm using httplib2.

My two particular questions:

1) When I set my 'body' var, (i.e. 'body = {'query':'search_term'}),
how do I know what the particular key should be? In other words, how
do I tell python which form on the web page I'm visiting I'd like to
fill in? Do I simply go to the webpage itself and look at the html
source? But if that's the case, which tag tells me the name of the
key?

2) Even once python fills in the form properly, how can I tell it to
'submit' the search?

Thanks all!

Matt
  


--
http://mail.python.org/mailman/listinfo/python-list


Re: python and http POST

2010-02-11 Thread Terry Reedy

On 2/11/2010 2:11 PM, galileo228 wrote:

Hey All,

Been teaching myself Python for a few weeks, and am trying to write a
program that will go to a url, enter a string in one of the search
fields, submit the search, and return the contents of the search
result.

I'm using httplib2.

My two particular questions:

1) When I set my 'body' var, (i.e. 'body = {'query':'search_term'}),
how do I know what the particular key should be? In other words, how
do I tell python which form on the web page I'm visiting I'd like to
fill in? Do I simply go to the webpage itself and look at the html
source? But if that's the case, which tag tells me the name of the
key?

2) Even once python fills in the form properly, how can I tell it to
'submit' the search?


This
http://groups.csail.mit.edu/uid/sikuli/
*might* help you.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Trouble sending / receiving compressed data (using zlib) as HTTP POST to server (in django)

2009-10-05 Thread subeen
Thanks for your response.
 How did you post the data? If you post binary data you should indicate
 this with a proper mime type, like application/octet-stream. Otherwise
 it might be interpreted as text which it isn't.
 --
I am trying to send the data using following code:
...
opener = urllib2.build_opener()

opener.addheaders = [

 ('User-Agent', 'python'),
 ('Content-Type', 'application/octet-stream'),
]
data = zlib.compress(data)
params = urllib.urlencode({'uid': uid, 'reqid': rid, 'data':
data})
usock = opener.open(url, params)
resp = usock.read()

usock.close()
...

regards,
Subeen.
-- 
http://mail.python.org/mailman/listinfo/python-list


Trouble sending / receiving compressed data (using zlib) as HTTP POST to server (in django)

2009-10-03 Thread subeen
Hi,

I am trying to send compressed data to a server written in django. But
it shows error while decompressing the data in the server. After some
experiment I found that the server is not receiving the exact data I
am sending.

data = 'hello, this is a test message this is another message'
data = zlib.compress(data)
# now it looks like: x��HQ(��,V�D���T�p^~IFjL�e
# length is 45

in django (view) I receive it:
data = request.POST['data']
# now it looks like: xQ(�,V�D���^~IFjL�e
# length is 34

Can anybody help me understand the issue and how to get over?


thanks,
Subeen.
http://love-python.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Trouble sending / receiving compressed data (using zlib) as HTTP POST to server (in django)

2009-10-03 Thread Piet van Oostrum
 subeen tamim.shahr...@gmail.com (s) wrote:

s Hi,
s I am trying to send compressed data to a server written in django. But
s it shows error while decompressing the data in the server. After some
s experiment I found that the server is not receiving the exact data I
s am sending.

s data = 'hello, this is a test message this is another message'
s data = zlib.compress(data)
s # now it looks like: x��HQ(��,V�D.���T�p^~IFj.L.�.e
s # length is 45

Note: you can't just paste binary data in the message and expect
something sensible. Better use the result of 'print data'.

s in django (view) I receive it:
s data = request.POST['data']
s # now it looks like: xQ(�,V�D���.^~IFj.L.�.e
s # length is 34

s Can anybody help me understand the issue and how to get over?

How did you post the data? If you post binary data you should indicate
this with a proper mime type, like application/octet-stream. Otherwise
it might be interpreted as text which it isn't.
-- 
Piet van Oostrum p...@vanoostrum.org
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP POST File without cURL

2009-09-11 Thread John Giotta
Is there a verbose feature for urllib2.urlopen?

Here is my python snippet for posted the file:

req = urllib2.Request(url='https://%s%s' % (host, selector),
data=open('test.zip', 'rb').read())
req.add_header('content-type', 'application/zip')
req.add_header('Authorization', 'Basic %s' % self.auth)
#req.add_header('content-length', str(len(body)))
print req.headers
u = urllib2.urlopen(req)
-- 
http://mail.python.org/mailman/listinfo/python-list


HTTP POST File without cURL

2009-09-09 Thread John D Giotta
I'm working with an API that allows me to POST a zip file via HTTP and
the documentation uses a cURL example. cURL works, but when I try to
POST the file via python it fails.
I don't want to use cURL (since I'm trying to be transparent and
dependency-less), but I can't find anything online that works.

When I use multipart/form-data methods (found here
http://code.activestate.com/recipes/146306/), the recipient cannot
decipher the attached file.

This is about the most difficult thing I've had to do with python and
yet it is supposed to be the very basics of HTTP.

Example cURL command:
curl -v -u username:passwd --data-binary @/home/jdgiotta/test.zip -H
Content-Type: application/zip https://host/selector

Is there a valid way to do this?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP POST File without cURL

2009-09-09 Thread David Stanek
On Wed, Sep 9, 2009 at 1:57 PM, John D Giottajdgio...@gmail.com wrote:
 I'm working with an API that allows me to POST a zip file via HTTP and
 the documentation uses a cURL example. cURL works, but when I try to
 POST the file via python it fails.
 I don't want to use cURL (since I'm trying to be transparent and
 dependency-less), but I can't find anything online that works.

 When I use multipart/form-data methods (found here
 http://code.activestate.com/recipes/146306/), the recipient cannot
 decipher the attached file.

 This is about the most difficult thing I've had to do with python and
 yet it is supposed to be the very basics of HTTP.

 Example cURL command:
 curl -v -u username:passwd --data-binary @/home/jdgiotta/test.zip -H
 Content-Type: application/zip https://host/selector

 Is there a valid way to do this?


Without seeing code it is hard to tell what is happening. What I would
do is capture the HTTP traffic and compare Python to cURL. Then you'll
know how to change you script.

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HTTP POST File without cURL

2009-09-09 Thread Jarkko Torppa
On 2009-09-09, John D Giotta jdgio...@gmail.com wrote:
 I'm working with an API that allows me to POST a zip file via HTTP and
 the documentation uses a cURL example. cURL works, but when I try to
 POST the file via python it fails.
 I don't want to use cURL (since I'm trying to be transparent and
 dependency-less), but I can't find anything online that works.

 When I use multipart/form-data methods (found here
 http://code.activestate.com/recipes/146306/), the recipient cannot
 decipher the attached file.

 This is about the most difficult thing I've had to do with python and
 yet it is supposed to be the very basics of HTTP.

 Example cURL command:
 curl -v -u username:passwd --data-binary @/home/jdgiotta/test.zip -H
 Content-Type: application/zip https://host/selector

 Is there a valid way to do this?

Maybe, but reading from curl manpage it seems that that is doing

POST /selector ...
Content-type: application/zip

data


The backend is broken, they should have used PUT for that. Search
for python http put and adapt, or lookt at urllib(2)/httplib and
roll your own.

-- 
Jarkko Torppa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: logging outgoing HTTP POST message and incoming response message

2009-07-23 Thread Gabriel Genellina

En Wed, 22 Jul 2009 18:18:37 -0300, scriptlear...@gmail.com
scriptlear...@gmail.com escribió:

On Jul 22, 1:54 pm, Diez B. Roggisch de...@nospam.web.de wrote:

You can use proxy-tools such as tcpmon or sniff traffic using wireshark.


Thanks,
but I am trying to enable some debug mode to log all outgoing and
incoming messages for certain period of time, and running another
proxy-tool is not very ideal.  It would be great to log it in some log
file.


You may install a custom HTTPHandler:

class LoggingHTTPConnection(httplib.HTTPConnection):

 def request(self, method, url, body=None, headers={}):
 print method, url, headers
 httplib.HTTPConnection.request(self, method, url, body, headers)

 def getresponse(self):
 response = httplib.HTTPConnection.getresponse(self)
 print response.status, response.msg
 return response

class LoggingHTTPHandler(urllib2.HTTPHandler):
 def http_open(self, req):
 return self.do_open(LoggingHTTPConnection, req)

opener = urllib2.build_opener(LoggingHTTPHandler, ...)

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list


Re: logging outgoing HTTP POST message and incoming response message

2009-07-22 Thread scriptlear...@gmail.com
On Jul 22, 1:54 pm, Diez B. Roggisch de...@nospam.web.de wrote:
 You can use proxy-tools such as tcpmon or sniff traffic using wireshark.

 Diez

Thanks,
but I am trying to enable some debug mode to log all outgoing and
incoming messages for certain period of time, and running another
proxy-tool is not very ideal.  It would be great to log it in some log
file.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHON HTTP POST WORKING EXAMPLE NEEDED

2009-01-23 Thread Benjamin Kaplan
On Fri, Jan 23, 2009 at 8:02 PM, r rt8...@gmail.com wrote:

 Whatever scumbag would rate a new python's users with one start for
 asking us for help is a complete low-life. Keep acting like that and
 Python will fade away into the darkness forever.



Could you please explain where these stars you keep talking about come from?
It's not from Usenet (AFAIKT), the mailing list, or Google Groups. Stop
worrying about something that 99% of the people here can't see.




 dhaval,
 Don't let the few bullies here scare you away, try out the this link,
 the other one i gave you was incorrect

 http://www.python-forum.org/pythonforum/index.php
 --
 http://mail.python.org/mailman/listinfo/python-list

--
http://mail.python.org/mailman/listinfo/python-list


RE: PYTHON HTTP POST WORKING EXAMPLE NEEDED

2009-01-23 Thread bruce
hey

didn't get the initial post/ just what is the original poster looking for??



-Original Message-
From: python-list-bounces+bedouglas=earthlink@python.org
[mailto:python-list-bounces+bedouglas=earthlink@python.org]on Behalf
Of r
Sent: Friday, January 23, 2009 5:03 PM
To: python-list@python.org
Subject: Re: PYTHON HTTP POST WORKING EXAMPLE NEEDED


Whatever scumbag would rate a new python's users with one start for
asking us for help is a complete low-life. Keep acting like that and
Python will fade away into the darkness forever.


dhaval,
Don't let the few bullies here scare you away, try out the this link,
the other one i gave you was incorrect

http://www.python-forum.org/pythonforum/index.php
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list


PYTHON HTTP POST

2009-01-14 Thread lilanidhaval
Hi,

I need one complete example of how to do a http post to any site.
I have tried making a POST to google but all I am returned with is a
405 error.
I don't want to use Pygoogle as I want to try and do this with other
sites.
I am also having problems inputing with the param
I have tried Mechanize. There are no problems with getting data only
posting.

 headers = {'Content-Type': 'text/html; charset=ISO-8859-1',
... 'User-Agent':'Mozilla/4.0',
... 'Content-Length':'7'}
 conn = httplib.HTTPConnection(www.google.com)
 conn.request(POST,/search,params,headers)
 r2 =  conn.getresponse()
 print r2.status, r2.reason
405 Method Not Allowed

Regards,
Dhaval
--
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHON HTTP POST

2009-01-14 Thread koranthala
Does google accept POST?

Anyways, if you dont need to post files, you can use urlencode itself.
def encode_formdata(fields):
body = urllib.urlencode(dict(fields))
content_type = application/x-www-form-urlencoded
return content_type, body

If you need to post files too, then you will have to use multipart
data
def encode_multipart_formdata(fields, files):

fields is a sequence of (name, value) elements for regular form
fields.
files is a sequence of (name, filename, value) elements for data
to be uploaded as files
Return (content_type, body) ready for httplib.HTTP instance

BOUNDARY = '--ThIs_Is_tHe_bouNdaRY_$'
CRLF = '\r\n'
L = []
for (key, value) in fields:
L.append('--' + BOUNDARY)
L.append('Content-Disposition: form-data; name=%s' % key)
L.append('')
L.append(value)
for (key, filename, value) in files:
L.append('--' + BOUNDARY)
L.append('Content-Disposition: form-data; name=%s;
filename=%s' % (key, filename))
L.append('Content-Type: %s' % mimetypes.guess_type(filename)
[0] or 'application/octet-stream'
L.append('')
L.append(value)
L.append('--' + BOUNDARY + '--')
L.append('')
body = CRLF.join(L)
content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
return content_type, body

Since POST files doesnt work with urllib, you might have to use
httplib - or go for very high level tools like twisted.
I here show an example with httplib.

def post(host, selector, fields, files):
if files:
   content_type, body = encode_multipart_formdata(fields, files)
else:
   content_type, body = encode_formdata(fields)

h = httplib.HTTPConnection(host)
#Spoof Mozilla
headers = {
'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4',
'Content-Type': content_type
}
h.request('POST', selector, body, headers)
res = h.getresponse()
return res.status, res.reason, res.read()

Please note that you can use multipart whether or not files are there,
but parsing multipart usually is slower.

Hope this helps.

lilanidha...@gmail.com wrote:
 Hi,

 I need one complete example of how to do a http post to any site.
 I have tried making a POST to google but all I am returned with is a
 405 error.
 I don't want to use Pygoogle as I want to try and do this with other
 sites.
 I am also having problems inputing with the param
 I have tried Mechanize. There are no problems with getting data only
 posting.

  headers = {'Content-Type': 'text/html; charset=ISO-8859-1',
 ... 'User-Agent':'Mozilla/4.0',
 ... 'Content-Length':'7'}
  conn = httplib.HTTPConnection(www.google.com)
  conn.request(POST,/search,params,headers)
  r2 =  conn.getresponse()
  print r2.status, r2.reason
 405 Method Not Allowed

 Regards,
 Dhaval
--
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHON HTTP POST

2009-01-14 Thread koranthala
On Jan 14, 2:21 pm, koranth...@gmail.com wrote:
 Does google accept POST?

 Anyways, if you dont need to post files, you can use urlencode itself.
 def encode_formdata(fields):
         body = urllib.urlencode(dict(fields))
         content_type = application/x-www-form-urlencoded
         return content_type, body

 If you need to post files too, then you will have to use multipart
 data
 def encode_multipart_formdata(fields, files):
     
     fields is a sequence of (name, value) elements for regular form
 fields.
     files is a sequence of (name, filename, value) elements for data
 to be uploaded as files
     Return (content_type, body) ready for httplib.HTTP instance
     
     BOUNDARY = '--ThIs_Is_tHe_bouNdaRY_$'
     CRLF = '\r\n'
     L = []
     for (key, value) in fields:
         L.append('--' + BOUNDARY)
         L.append('Content-Disposition: form-data; name=%s' % key)
         L.append('')
         L.append(value)
     for (key, filename, value) in files:
         L.append('--' + BOUNDARY)
         L.append('Content-Disposition: form-data; name=%s;
 filename=%s' % (key, filename))
         L.append('Content-Type: %s' % mimetypes.guess_type(filename)
 [0] or 'application/octet-stream'
         L.append('')
         L.append(value)
     L.append('--' + BOUNDARY + '--')
     L.append('')
     body = CRLF.join(L)
     content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
     return content_type, body

 Since POST files doesnt work with urllib, you might have to use
 httplib - or go for very high level tools like twisted.
 I here show an example with httplib.

 def post(host, selector, fields, files):
     if files:
        content_type, body = encode_multipart_formdata(fields, files)
     else:
        content_type, body = encode_formdata(fields)

     h = httplib.HTTPConnection(host)
     #Spoof Mozilla
     headers = {
         'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
 rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4',
         'Content-Type': content_type
         }
     h.request('POST', selector, body, headers)
     res = h.getresponse()
     return res.status, res.reason, res.read()

 Please note that you can use multipart whether or not files are there,
 but parsing multipart usually is slower.

 Hope this helps.

 lilanidha...@gmail.com wrote:
  Hi,

  I need one complete example of how to do a http post to any site.
  I have tried making a POST to google but all I am returned with is a
  405 error.
  I don't want to use Pygoogle as I want to try and do this with other
  sites.
  I am also having problems inputing with the param
  I have tried Mechanize. There are no problems with getting data only
  posting.

   headers = {'Content-Type': 'text/html; charset=ISO-8859-1',
  ...         'User-Agent':'Mozilla/4.0',
  ...         'Content-Length':'7'}
   conn = httplib.HTTPConnection(www.google.com)
   conn.request(POST,/search,params,headers)
   r2 =  conn.getresponse()
   print r2.status, r2.reason
  405 Method Not Allowed

  Regards,
  Dhaval



oops - Forgot to mention that POSTing files mechanism is taken from a
recipe in active state -
http://code.activestate.com/recipes/146306/
--
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHON HTTP POST

2009-01-14 Thread dhaval
The action part of the field is not set to anything.
I need any site with working example that accepts POST.

On Jan 14, 2:21 pm, koranth...@gmail.com wrote:
 Does google accept POST?

 Anyways, if you dont need to post files, you can use urlencode itself.
 def encode_formdata(fields):
 body = urllib.urlencode(dict(fields))
 content_type = application/x-www-form-urlencoded
 return content_type, body

 If you need to post files too, then you will have to use multipart
 data
 def encode_multipart_formdata(fields, files):
 
 fields is a sequence of (name, value) elements for regular form
 fields.
 files is a sequence of (name, filename, value) elements for data
 to be uploaded as files
 Return (content_type, body) ready for httplib.HTTP instance
 
 BOUNDARY = '--ThIs_Is_tHe_bouNdaRY_$'
 CRLF = '\r\n'
 L = []
 for (key, value) in fields:
 L.append('--' + BOUNDARY)
 L.append('Content-Disposition: form-data; name=%s' % key)
 L.append('')
 L.append(value)
 for (key, filename, value) in files:
 L.append('--' + BOUNDARY)
 L.append('Content-Disposition: form-data; name=%s;
 filename=%s' % (key, filename))
 L.append('Content-Type: %s' % mimetypes.guess_type(filename)
 [0] or 'application/octet-stream'
 L.append('')
 L.append(value)
 L.append('--' + BOUNDARY + '--')
 L.append('')
 body = CRLF.join(L)
 content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
 return content_type, body

 Since POST files doesnt work with urllib, you might have to use
 httplib - or go for very high level tools like twisted.
 I here show an example with httplib.

 def post(host, selector, fields, files):
 if files:
content_type, body = encode_multipart_formdata(fields, files)
 else:
content_type, body = encode_formdata(fields)

 h = httplib.HTTPConnection(host)
 #Spoof Mozilla
 headers = {
 'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
 rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4',
 'Content-Type': content_type
 }
 h.request('POST', selector, body, headers)
 res = h.getresponse()
 return res.status, res.reason, res.read()

 Please note that you can use multipart whether or not files are there,
 but parsing multipart usually is slower.

 Hope this helps.

 lilanidha...@gmail.com wrote:
  Hi,

  I need one complete example of how to do a http post to any site.
  I have tried making a POST to google but all I am returned with is a
  405 error.
  I don't want to use Pygoogle as I want to try and do this with other
  sites.
  I am also having problems inputing with the param
  I have tried Mechanize. There are no problems with getting data only
  posting.

   headers = {'Content-Type': 'text/html; charset=ISO-8859-1',
  ... 'User-Agent':'Mozilla/4.0',
  ... 'Content-Length':'7'}
   conn = httplib.HTTPConnection(www.google.com)
   conn.request(POST,/search,params,headers)
   r2 =  conn.getresponse()
   print r2.status, r2.reason
  405 Method Not Allowed

  Regards,
  Dhaval

--
http://mail.python.org/mailman/listinfo/python-list


PYTHON HTTP POST WORKING EXAMPLE NEEDED

2009-01-14 Thread dhaval
Hi,

Can someone please give me an example of a working python post?
for example using the site http://www.cookiemag.com/

Thanks in advance,
Dhaval
--
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHON HTTP POST WORKING EXAMPLE NEEDED

2009-01-14 Thread dhaval
On Jan 14, 4:11 pm, dhaval lilanidha...@gmail.com wrote:
 Hi,

 Can someone please give me an example of a working python post?
 for example using the sitehttp://www.cookiemag.com/

 Thanks in advance,
 Dhaval

I have tried to look at the code at
http://code.activestate.com/recipes/146306/
I can't make any sense out of it.
--
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHON HTTP POST WORKING EXAMPLE NEEDED

2009-01-14 Thread Diez B. Roggisch
dhaval wrote:

 On Jan 14, 4:11 pm, dhaval lilanidha...@gmail.com wrote:
 Hi,

 Can someone please give me an example of a working python post?
 for example using the sitehttp://www.cookiemag.com/

 Thanks in advance,
 Dhaval
 
 I have tried to look at the code at
 http://code.activestate.com/recipes/146306/
 I can't make any sense out of it.

 - don't SHOUT.
 - don't open up new threads 2 hours after you asked the first time with the
*same* question.
 - show code of your actual efforts. This is not the free code snippets
producing system.
 - read this: http://www.catb.org/~esr/faqs/smart-questions.html

Diez
--
http://mail.python.org/mailman/listinfo/python-list


Posting File as a parameter to PHP/HTML using HTTP POST

2008-12-02 Thread S.Selvam Siva
I am trying to post file from python to php using HTTP POST method. I tried
mechanize but not able to pass the file object.

from mechanize import Browser
br=Browser()
response=br.open(http://localhost/test.php;)
br.select_form('form1')
br['uploadedfile']=open(C:/Documents and
Settings/user/Desktop/Today/newurl-ideas.txt)
response=br.submit()
print response.read()

But, i get the error:
br['uploadedfile']=open(C:/Documents and
Settings/user/Desktop/Today/newurl
-ideas.txt)
  File
C:\Python25\lib\site-packages\clientform-0.2.9-py2.5.egg\ClientForm.py,
 line 2880, in __setitem__
ValueError: value attribute is readonly

But,
When uploading is done using browser, it works.
-- 
Yours,
S.Selvam
--
http://mail.python.org/mailman/listinfo/python-list


Re: Posting File as a parameter to PHP/HTML using HTTP POST

2008-12-02 Thread S.Selvam Siva
I myself have found the solution.

Instead of:
br[br['uploadedfile']=open(C:/

 Documents and Settings/user/Desktop/Today/newurl-ideas.txt)


We Need to use:
br.add_file(open(C:/

 Documents and Settings/user/Desktop/Today/newurl-ideas.txt),
 filename=newurl-ideas.txt,name=uploadedfile)



On Tue, Dec 2, 2008 at 1:33 PM, S.Selvam Siva [EMAIL PROTECTED]wrote:

 I am trying to post file from python to php using HTTP POST method. I tried
 mechanize but not able to pass the file object.

 from mechanize import Browser
 br=Browser()
 response=br.open(http://localhost/test.php;)
 br.select_form('form1')
 br['uploadedfile']=open(C:/Documents and
 Settings/user/Desktop/Today/newurl-ideas.txt)
 response=br.submit()
 print response.read()

 But, i get the error:
 br['uploadedfile']=open(C:/Documents and
 Settings/user/Desktop/Today/newurl
 -ideas.txt)
   File
 C:\Python25\lib\site-packages\clientform-0.2.9-py2.5.egg\ClientForm.py,
  line 2880, in __setitem__
 ValueError: value attribute is readonly

 But,
 When uploading is done using browser, it works.
 --
 Yours,
 S.Selvam




-- 
Yours,
S.Selvam
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >