henrik242 <hen...@synth.no> added the comment:

Solved! 

The problem was Solr which it has special handling of POSTed data with the 
User-Agent starts with 'curl/': 
https://github.com/apache/lucene-solr/blob/40661489cd590947f513e553a20707d0c82b82e5/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java#L782

In all other cases Solr expects the Content-Type to be text/xml.  Setting that 
with urrlib.request makes the request work fine:

>>> req = urllib.request.Request(url, data.encode('utf-8'), 
>>> headers={'Content-Type': 'text/xml'})
>>> res = urllib.request.urlopen(req)

A big thanks to https://stackoverflow.com/a/60586102/13365 for figuring this out

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39875>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to