Esempio n. 1
0
        response = Response(headers=response_headers)

        try:
            retriever = Retriever(self._interaction_pool, self._redis_queue,
                                  collection_row["id"],
                                  collection_row["versioning"], key,
                                  version_id, slice_offset, slice_size,
                                  user_request_id)

            # the exception blocks below will only catch exceptions before the
            # first yield of the generator, at which point we hand the
            # retrieve_generator off to webob.
            # so, don't let exceptions inside the generator by handled by webob
            # before we get a chance to log them! wrap it in this.
            retrieve_generator = iter_exception_logger(
                "retrieve_generator", "request %s: " % (user_request_id, ),
                retriever.retrieve, response, _reply_timeout)

        except RetrieveFailedError, instance:
            self._log.error("retrieve failed: %s %s" % (
                description,
                instance,
            ))
            if "content-length" in req.headers:
                queue_entry = \
                    redis_queue_entry_tuple(timestamp=create_timestamp(),
                                            collection_id=collection_row["id"],
                                            value=req.headers["content-length"])
                self._redis_queue.put((
                    "error_bytes_in",
                    queue_entry,
Esempio n. 2
0
        response_headers = dict()
        if "range" in req.headers:
            status_int = httplib.PARTIAL_CONTENT
            response_headers["Content-Range"] = \
                _content_range_header(lower_bound,
                                      upper_bound,
                                      total_file_size)
            response_headers["Content-Length"] = slice_size
        else:
            status_int = httplib.OK

        response = Response(headers=response_headers)

        # Ticket #31 Guess Content-Type and Content-Encoding
        response.content_type = "application/octet-stream"

        response.status_int = status_int

        # the exception blocks below will only catch exceptions before the
        # first yield of the generator, at which point we hand the
        # retrieve_generator off to webob.
        # so, don't let exceptions inside the generator by handled by webob
        # before we get a chance to log them! wrap it in this.
        retrieve_generator = iter_exception_logger(
            "internal_retrieve_generator",
            "request %s: " % (user_request_id, ), app_iterator, response)

        response.app_iter = retrieve_generator
        return response
Esempio n. 3
0
                collection_row["id"],
                collection_row["versioning"],
                key,
                version_id,
                slice_offset,
                slice_size,
                user_request_id,
            )

            # the exception blocks below will only catch exceptions before the
            # first yield of the generator, at which point we hand the
            # retrieve_generator off to webob.
            # so, don't let exceptions inside the generator by handled by webob
            # before we get a chance to log them! wrap it in this.
            retrieve_generator = iter_exception_logger(
                "retrieve_generator", "request %s: " % (user_request_id,), retriever.retrieve, response, _reply_timeout
            )

        except RetrieveFailedError, instance:
            self._log.error("retrieve failed: %s %s" % (description, instance))
            if "content-length" in req.headers:
                queue_entry = redis_queue_entry_tuple(
                    timestamp=create_timestamp(),
                    collection_id=collection_row["id"],
                    value=req.headers["content-length"],
                )
                self._redis_queue.put(("error_bytes_in", queue_entry))
            return exc.HTTPNotFound(str(instance))
        except Exception, instance:
            self._log.exception("retrieve_generator init exception: {0}".format(instance))
            self._event_push_client.exception(
Esempio n. 4
0
            status_int = httplib.PARTIAL_CONTENT
            response_headers["Content-Range"] = \
                _content_range_header(lower_bound,
                                      upper_bound,
                                      total_file_size)
            response_headers["Content-Length"] = slice_size
        else:
            status_int = httplib.OK

        response = Response(headers=response_headers)
        
        # Ticket #31 Guess Content-Type and Content-Encoding
        response.content_type = "application/octet-stream"

        response.status_int = status_int

        # the exception blocks below will only catch exceptions before the
        # first yield of the generator, at which point we hand the
        # retrieve_generator off to webob.
        # so, don't let exceptions inside the generator by handled by webob
        # before we get a chance to log them! wrap it in this.
        retrieve_generator = iter_exception_logger(
            "internal_retrieve_generator", 
            "request %s: " % (user_request_id, ),
            app_iterator,
            response)

        response.app_iter = retrieve_generator
        return  response