]> projects.mako.cc - mw/commitdiff
Set custom User-Agent header
authorIan Weller <ian@ianweller.org>
Mon, 15 Mar 2010 01:58:05 +0000 (20:58 -0500)
committerIan Weller <ian@ianweller.org>
Mon, 15 Mar 2010 01:59:54 +0000 (20:59 -0500)
src/mw/__init__.py
src/mw/api.py

index 65d03c449861f2a02e7c89276c142cee65988e66..5ef42b57dca5e49fa923c8d2b72de7bdb17ae056 100644 (file)
@@ -15,3 +15,5 @@
 # You should have received a copy of the GNU General Public License along
 # with this program.  If not, see <http://www.gnu.org/licenses/>.
 ###
+
+version = '0.1'
index f5dbdec160256834c108d1d40818ebc0ae80263f..6aec91c7b36a72353b328c2872e9da0b4882865b 100644 (file)
@@ -19,6 +19,7 @@
 import cookielib
 import gzip
 import json
+import mw
 import mw.metadir
 import os
 from StringIO import StringIO
@@ -44,7 +45,9 @@ class API(object):
 
     def call(self, data):
         data['format'] = 'json'
-        request = urllib2.Request(self.api_url, urllib.urlencode(data))
+        user_agent = 'mw/%s +http://github.com/ianweller/mw' % mw.version
+        request = urllib2.Request(self.api_url, urllib.urlencode(data),
+                                  {'User-Agent': user_agent})
         request.add_header('Accept-encoding', 'gzip')
         response = self.opener.open(request)
         self.cookiejar.save()

Benjamin Mako Hill || Want to submit a patch?