# Path: spacescout_web/middleware/unpatch_vary.py
# def unpatch_vary_headers(response, headers):
#     """Add the headers to the list of unpatch vary headers.
#     """
#     unpatch_headers = re.split(r'\s*,\s*',
#                                response.get(HEADER_UNPATCH_VARY, ''))
#     unpatch_headers.extend(headers)
#     response[HEADER_UNPATCH_VARY] = ','.join(unpatch_headers)
#     return response


from django.http import HttpResponse, HttpResponseNotFound
from django.conf import settings
from django.core.cache import cache
from spacescout_web.middleware.unpatch_vary import unpatch_vary_headers
import urllib
import oauth2
import types
import hashlib
""" Copyright 2012, 2013 UW Information Technology, University of Washington

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
"""



def ImageView(
            request, spot_id, image_id, thumb_width=None,
            thumb_height=None, constrain=False):

    client = get_client()
    contenttype, img = get_image(
                                client, spot_id, image_id,
                                constrain, thumb_width, thumb_height)

    response = HttpResponse(img, content_type=contenttype)
    # Remove some headers that don't vary for images

# Path: spacescout_web/middleware/unpatch_vary.py
# def unpatch_vary_headers(response, headers):
#     """Add the headers to the list of unpatch vary headers.
#     """
#     unpatch_headers = re.split(r'\s*,\s*',
#                                response.get(HEADER_UNPATCH_VARY, ''))
#     unpatch_headers.extend(headers)
#     response[HEADER_UNPATCH_VARY] = ','.join(unpatch_headers)
#     return response


# Path: spacescout_web/views/image.py
from django.http import HttpResponse, HttpResponseNotFound
from django.conf import settings
from django.core.cache import cache
from spacescout_web.middleware.unpatch_vary import unpatch_vary_headers
import urllib
import oauth2
import types
import hashlib

""" Copyright 2012, 2013 UW Information Technology, University of Washington

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
"""



def ImageView(
            request, spot_id, image_id, thumb_width=None,
            thumb_height=None, constrain=False):

    client = get_client()
    contenttype, img = get_image(
                                client, spot_id, image_id,
                                constrain, thumb_width, thumb_height)

    response = HttpResponse(img, content_type=contenttype)
    # Remove some headers that don't vary for images

    unpatch_vary_headers(response, [