Skip to content

Commit

Permalink
add jpeg support to proxy server
Browse files Browse the repository at this point in the history
  • Loading branch information
chekunkov committed Jul 29, 2015
1 parent 3e37339 commit 640ff7e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions splash/proxy_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
from __future__ import absolute_import
from twisted.web import http
from twisted.web.error import UnsupportedMethod
from twisted.python import log, failure
from twisted.python import failure
from splash.resources import (RenderHtmlResource, RenderPngResource,
RenderJsonResource)
RenderJpegResource, RenderJsonResource)

NOT_DONE_YET = 1
SPLASH_HEADER_PREFIX = 'x-splash-'
SPLASH_RESOURCES = {
'html': RenderHtmlResource,
'png': RenderPngResource,
'jpeg': RenderJpegResource,
'json': RenderJsonResource,
}

Expand All @@ -25,7 +26,8 @@
'viewport', 'js', 'js-source', 'images', 'filters',
'render-all', 'scale-method']
PNG_PARAMS = ['width', 'height']
JSON_PARAMS = ['html', 'png', 'iframes', 'script', 'console', 'history', 'har']
JPEG_PARAMS = ['width', 'height', 'quality']
JSON_PARAMS = ['html', 'png', 'jpeg', 'iframes', 'script', 'console', 'history', 'har']

HOP_BY_HOP_HEADERS = [
'Connection',
Expand Down Expand Up @@ -117,8 +119,10 @@ def process(self):

if resource_name == 'png':
self._fill_args_from_headers(PNG_PARAMS)
elif resource_name == 'jpeg':
self._fill_args_from_headers(JPEG_PARAMS)
elif resource_name == 'json':
self._fill_args_from_headers(PNG_PARAMS)
self._fill_args_from_headers(JPEG_PARAMS)
self._fill_args_from_headers(JSON_PARAMS)

# make sure no splash headers are sent to the target
Expand Down

0 comments on commit 640ff7e

Please sign in to comment.