Permalink
Browse files

Updated most JSON mime-types from text/json to application/json, closes

  • Loading branch information...
1 parent 3b34963 commit 0fa095324954f2edfbe830eadc2a21d96c74f8ce @migurski migurski committed Jun 23, 2013
View
2 TileStache/Goodies/Providers/PostGeoJSON.py
@@ -241,7 +241,7 @@ def getTypeByExtension(self, extension):
if extension.lower() != 'json':
raise KnownUnknown('PostGeoJSON only makes .json tiles, not "%s"' % extension)
- return 'text/json', 'JSON'
+ return 'application/json', 'JSON'
def renderTile(self, width, height, srs, coord):
""" Render a single tile, return a SaveableResponse instance.
View
2 TileStache/Goodies/Providers/SolrGeoJSON.py
@@ -118,7 +118,7 @@ def getTypeByExtension(self, extension):
if extension.lower() != 'json':
raise KnownUnknown('PostGeoJSON only makes .json tiles, not "%s"' % extension)
- return 'text/json', 'JSON'
+ return 'application/json', 'JSON'
def unproject(self, x, y):
x, y = x / 6378137, y / 6378137 # dimensions of the earth
View
4 TileStache/Goodies/VecTiles/server.py
@@ -164,7 +164,7 @@ def getTypeByExtension(self, extension):
return 'application/octet-stream+mvt', 'MVT'
elif extension.lower() == 'json':
- return 'text/json', 'JSON'
+ return 'application/json', 'JSON'
elif extension.lower() == 'topojson':
return 'application/json', 'TopoJSON'
@@ -205,7 +205,7 @@ def getTypeByExtension(self, extension):
''' Get mime-type and format by file extension, "json" or "topojson" only.
'''
if extension.lower() == 'json':
- return 'text/json', 'JSON'
+ return 'application/json', 'JSON'
elif extension.lower() == 'topojson':
return 'application/json', 'TopoJSON'
View
6 TileStache/MBTiles.py
@@ -153,7 +153,7 @@ def get_tile(filename, coord):
db = _connect(filename)
db.text_factory = bytes
- formats = {'png': 'image/png', 'jpg': 'image/jpeg', 'json': 'text/json', None: None}
+ formats = {'png': 'image/png', 'jpg': 'image/jpeg', 'json': 'application/json', None: None}
format = db.execute("SELECT value FROM metadata WHERE name='format'").fetchone()
format = format and format[0] or None
mime_type = formats[format]
@@ -215,7 +215,7 @@ def renderTile(self, width, height, srs, coord):
""" Retrieve a single tile, return a TileResponse instance.
"""
mime_type, content = get_tile(self.tileset, coord)
- formats = {'image/png': 'PNG', 'image/jpeg': 'JPEG', 'text/json': 'JSON', None: None}
+ formats = {'image/png': 'PNG', 'image/jpeg': 'JPEG', 'application/json': 'JSON', None: None}
return TileResponse(formats[mime_type], content)
def getTypeByExtension(self, extension):
@@ -224,7 +224,7 @@ def getTypeByExtension(self, extension):
This only accepts "png" or "jpg" or "json".
"""
if extension.lower() == 'json':
- return 'text/json', 'JSON'
+ return 'application/json', 'JSON'
elif extension.lower() == 'png':
return 'image/png', 'PNG'
View
4 TileStache/Vector/__init__.py
@@ -602,10 +602,10 @@ def getTypeByExtension(self, extension):
This only accepts "geojson" for the time being.
"""
if extension.lower() == 'geojson':
- return 'text/json', 'GeoJSON'
+ return 'application/json', 'GeoJSON'
elif extension.lower() == 'arcjson':
- return 'text/json', 'ArcJSON'
+ return 'application/json', 'ArcJSON'
elif extension.lower() == 'geobson':
return 'application/x-bson', 'GeoBSON'
View
10 tests/vector_tests.py
@@ -102,7 +102,7 @@ def test_points_geojson(self):
tile_mimetype, tile_content = utils.request(self.config_file_content, "vector_test", "geojson", 0, 0, 0)
geojson_result = json.loads(tile_content)
- self.assertEqual(tile_mimetype, "text/json")
+ self.assertTrue(tile_mimetype.endswith('/json'))
self.assertEqual(geojson_result['type'], 'FeatureCollection')
self.assertEqual(len(geojson_result['features']), 2)
@@ -128,7 +128,7 @@ def test_points_geojson(self):
tile_mimetype, tile_content = utils.request(self.config_file_content, "vector_test", "geojson", 0, 1, 0)
geojson_result = json.loads(tile_content)
- self.assertEqual(tile_mimetype, "text/json")
+ self.assertTrue(tile_mimetype.endswith('/json'))
self.assertEqual(geojson_result['type'], 'FeatureCollection')
self.assertEqual(len(geojson_result['features']), 1)
self.assertTrue('Berlin' in geojson_result['features'][0]['properties']['name'])
@@ -147,15 +147,15 @@ def test_linestring_geojson(self):
# for western hemisphere....
tile_mimetype, tile_content = utils.request(self.config_file_content, "vector_test", "geojson", 0, 0, 0)
- self.assertEqual(tile_mimetype, "text/json")
+ self.assertTrue(tile_mimetype.endswith('/json'))
geojson_result = json.loads(tile_content)
west_hemisphere_geometry = asShape(geojson_result['features'][0]['geometry'])
expected_geometry = LineString([(-180, 32), (0, 32)])
self.assertTrue(expected_geometry.almost_equals(west_hemisphere_geometry))
# for eastern hemisphere....
tile_mimetype, tile_content = utils.request(self.config_file_content, "vector_test", "geojson", 0, 1, 0)
- self.assertEqual(tile_mimetype, "text/json")
+ self.assertTrue(tile_mimetype.endswith('/json'))
geojson_result = json.loads(tile_content)
east_hemisphere_geometry = asShape(geojson_result['features'][0]['geometry'])
expected_geometry = LineString([(0, 32), (180, 32)])
@@ -178,7 +178,7 @@ def test_polygon_geojson(self):
self.insertTestRow(geom.wkt)
tile_mimetype, tile_content = utils.request(self.config_file_content, "vector_test", "geojson", 0, 0, 0)
- self.assertEqual(tile_mimetype, "text/json")
+ self.assertTrue(tile_mimetype.endswith('/json'))
geojson_result = json.loads(tile_content)
result_geom = asShape(geojson_result['features'][0]['geometry'])

0 comments on commit 0fa0953

Please sign in to comment.