Skip to content

Instantly share code, notes, and snippets.

@cgueret
Created June 3, 2015 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgueret/ee4e746211d41b8a68a1 to your computer and use it in GitHub Desktop.
Save cgueret/ee4e746211d41b8a68a1 to your computer and use it in GitHub Desktop.
Content negociation bug in Quilt
import requests
RESOURCE = "http://acropolis.org.uk/921df22045f949c5967a4d5e9dd0e653#id"
print "# No asking for anything"
r = requests.get(RESOURCE)
print 'Received {}'.format(r.headers['content-type'])
print r.text[:100]
print "\n# Asking for application/n-quads"
headers = {'Accept' : 'application/n-quads'}
r = requests.get(RESOURCE, headers=headers)
print 'Received {}'.format(r.headers['content-type'])
print r.text[:100]
print "\n# Asking for text/x-nquads"
headers = {'Accept' : 'text/x-nquads'}
r = requests.get(RESOURCE, headers=headers)
print 'Received {}'.format(r.headers['content-type'])
print r.text[:100]
print "\n# Asking for the same thing as rapper"
headers = {'Accept' : """application/rdf+xml, text/rdf;q=0.6,
application/n-triples, text/plain;q=0.1, text/turtle, application/x-turtle,
application/turtle, text/n3;q=0.3, text/rdf+n3;q=0.3, application/rdf+n3;q=0.3,
application/x-trig, application/rss;q=0.8, application/rss+xml;q=0.8,
text/rss;q=0.8, application/xml;q=0.3, text/xml;q=0.3,
application/atom+xml;q=0.3, text/html;q=0.2, application/xhtml+xml;q=0.4,
text/html;q=0.6, application/xhtml+xml;q=0.8,
text/x-nquads, /;q=0.1""".replace('\n',' ')}
r = requests.get(RESOURCE, headers=headers)
print 'Received {}'.format(r.headers['content-type'])
print r.text[:100]
@cgueret
Copy link
Author

cgueret commented Jun 3, 2015

Output :

No asking for anything

Received text/html; charset=utf-8

<title>Not acceptable</title> Received text/html; charset=utf-8

<title>Not acceptable</title> Received text/turtle; charset=utf-8
@Prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# .
@Prefix rdfs: <http://www.w3.org/2000/0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment