def _handle_head(gcs_stub, filename):
  """Handle HEAD request."""
  filestat = gcs_stub.head_object(filename)
  if not filestat:
    return _FakeUrlFetchResult(404, {}, '')

  http_time = common.posix_time_to_http(filestat.st_ctime)

  response_headers = {
      'content-length': filestat.st_size,
      'content-type': filestat.content_type,
      'etag': filestat.etag,
      'last-modified': http_time
  }

  if filestat.metadata:
    response_headers.update(filestat.metadata)

  return _FakeUrlFetchResult(200, response_headers, '')
Exemple #2
0
def _handle_head(gcs_stub, filename):
    """Handle HEAD request."""
    filestat = gcs_stub.head_object(filename)
    if not filestat:
        return _FakeUrlFetchResult(httplib.NOT_FOUND, {}, '')

    http_time = common.posix_time_to_http(filestat.st_ctime)

    response_headers = {
        'content-length': filestat.st_size,
        'content-type': filestat.content_type,
        'etag': filestat.etag,
        'last-modified': http_time
    }

    if filestat.metadata:
        response_headers.update(filestat.metadata)

    return _FakeUrlFetchResult(httplib.OK, response_headers, '')