Skip to content

Commit 897b9ad

Browse files
committed
sendMention now follows redirects if the POST was a 405 and the history has 301s - fix for Issue #9
1 parent b697a71 commit 897b9ad

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ronkyuu/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
__email__ = 'bear@bear.im'
99
__copyright__ = 'Copyright (c) 2013-2016 by Mike Taylor and Kartik Prabhu'
1010
__license__ = 'MIT'
11-
__version__ = '0.3.4'
11+
__version__ = '0.3.5'
1212
__url__ = 'https://github.com/bear/ronkyuu'
1313
__download_url__ = 'https://pypi.python.org/pypi/ronkyuu'
1414
__description__ = 'Webmention Manager'

ronkyuu/webmention.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ def sendWebmention(sourceURL, targetURL, webmention=None, test_urls=True, vouchD
189189
print 'sending to', wUrl, payload
190190
try:
191191
result = requests.post(wUrl, data=payload)
192+
193+
if result.status_code == 405 and len(result.history) > 0:
194+
o = result.history[-1]
195+
if o.status_code == 301 and 'Location' in o.headers:
196+
result = requests.post(o.headers['Location'], data=payload)
192197
except:
193198
result = None
194199
return result

0 commit comments

Comments
 (0)