# Path: django_eventstream/utils.py
# def add_default_headers(headers):
# 	headers['Cache-Control'] = 'no-cache'
# 	headers['X-Accel-Buffering'] = 'no'
# 	augment_cors_headers(headers)


from django.http import HttpResponseBadRequest
from .utils import add_default_headers
	from .eventrequest import EventRequest
	from .eventstream import EventPermissionError, get_events
	from .utils import sse_error_response
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


def events(request, **kwargs):

	try:
		event_request = EventRequest(request, view_kwargs=kwargs)
		event_response = get_events(event_request)
		response = event_response.to_http_response(request)
	except EventRequest.ResumeNotAllowedError as e:
		response = HttpResponseBadRequest(
			'Invalid request: %s.\n' % str(e))
	except EventRequest.GripError as e:
		if request.grip.proxied:
			response = sse_error_response(
				'internal-error',
				'Invalid internal request.')
		else:
			response = sse_error_response(
				'bad-request',
				'Invalid request: %s.' % str(e))
	except EventRequest.Error as e:
		response = sse_error_response(

# Path: django_eventstream/utils.py
# def add_default_headers(headers):
# 	headers['Cache-Control'] = 'no-cache'
# 	headers['X-Accel-Buffering'] = 'no'
# 	augment_cors_headers(headers)


# Path: django_eventstream/views.py
from django.http import HttpResponseBadRequest
from .utils import add_default_headers
	from .eventrequest import EventRequest
	from .eventstream import EventPermissionError, get_events
	from .utils import sse_error_response

# -*- coding: utf-8 -*-
from __future__ import unicode_literals


def events(request, **kwargs):

	try:
		event_request = EventRequest(request, view_kwargs=kwargs)
		event_response = get_events(event_request)
		response = event_response.to_http_response(request)
	except EventRequest.ResumeNotAllowedError as e:
		response = HttpResponseBadRequest(
			'Invalid request: %s.\n' % str(e))
	except EventRequest.GripError as e:
		if request.grip.proxied:
			response = sse_error_response(
				'internal-error',
				'Invalid internal request.')
		else:
			response = sse_error_response(
				'bad-request',
				'Invalid request: %s.' % str(e))
	except EventRequest.Error as e:
		response = sse_error_response(

			'bad-request',