code: def objects_get_common(bucket_name, object_name, revision):
      # Respect the Range: header, if present.
      range_header = flask.request.headers.get("range")
      response_payload = revision.media
      begin = 0
      end = len(response_payload)
      if range_header is not None:
          m = re.match("bytes=([0-9]+)-([0-9]+)", range_header)
          if m:
              begin = int(m.group(1))
              end = int(m.group(2))
              response_payload = response_payload[begin : end + 1]
          m = re.match("bytes=([0-9]+)-$", range_header)
          if m:
              begin = int(m.group(1))
              response_payload = response_payload[begin:]
          m = re.match("bytes=-([0-9]+)$", range_header)
          if m:
              last = int(m.group(1))
              response_payload = response_payload[-last:]
      # Process custom headers to test error conditions.
      instructions = flask.request.headers.get(
          "x-goog-testbench-instructions"
      )
      if instructions == "return-broken-stream":
  
          def streamer():
              chunk_size = 64 * 1024
              for r in range(0, len(response_payload), chunk_size):
                  if r > 1024 * 1024:
                      print("\n\n###### EXIT to simulate crash\n")
                      sys.exit(1)
                  time.sleep(0.1)
                  chunk_end = min(r + chunk_size, len(response_payload))
                  yield response_payload[r:chunk_end]
  
          length = len(response_payload)
          content_range = "bytes %d-%d/%d" % (begin, end - 1, length)
          headers = {
              "Content-Range": content_range,
              "Content-Length": length,
              "x-goog-hash": revision.x_goog_hash_header(),
              "x-goog-generation": revision.generation,
          }
          return flask.Response(streamer(), status=200, headers=headers)
  
      if instructions == "return-corrupted-data":
          response_payload = testbench_utils.corrupt_media(
              response_payload
          )
  
      if instructions is not None and instructions.startswith(
          "stall-always"
      ):
          length = len(response_payload)
          content_range = "bytes %d-%d/%d" % (begin, end - 1, length)
  
          def streamer():
              chunk_size = 16 * 1024
              for r in range(begin, end, chunk_size):
                  chunk_end = min(r + chunk_size, end)
                  if r == begin:
                      time.sleep(10)
                  yield response_payload[r:chunk_end]
  
          headers = {
              "Content-Range": content_range,
              "x-goog-hash": revision.x_goog_hash_header(),
              "x-goog-generation": revision.generation,
          }
          return flask.Response(streamer(), status=200, headers=headers)
  
      if instructions == "stall-at-256KiB" and begin == 0:
          length = len(response_payload)
          content_range = "bytes %d-%d/%d" % (begin, end - 1, length)
  
          def streamer():
              chunk_size = 16 * 1024
              for r in range(begin, end, chunk_size):
                  chunk_end = min(r + chunk_size, end)
                  if r == 256 * 1024:
                      time.sleep(10)
                  yield response_payload[r:chunk_end]
  
          headers = {
              "Content-Range": content_range,
              "x-goog-hash": revision.x_goog_hash_header(),
              "x-goog-generation": revision.generation,
          }
          return flask.Response(streamer(), status=200, headers=headers)
  
      if instructions is not None and instructions.startswith(
          "return-503-after-256K"
      ):
          length = len(response_payload)
          headers = {
              "Content-Range": "bytes %d-%d/%d"
              % (begin, end - 1, length),
              "x-goog-hash": revision.x_goog_hash_header(),
              "x-goog-generation": revision.generation,
          }
          if begin == 0:
  
              def streamer():
                  chunk_size = 4 * 1024
                  for r in range(0, len(response_payload), chunk_size):
                      if r >= 256 * 1024:
                          print("\n\n###### EXIT to simulate crash\n")
                          sys.exit(1)
                      time.sleep(0.01)
                      chunk_end = min(
                          r + chunk_size, len(response_payload)
                      )
                      yield response_payload[r:chunk_end]
  
              return flask.Response(
                  streamer(), status=200, headers=headers
              )
          if instructions.endswith("/retry-1"):
              print("## Return error for retry 1")
              return flask.Response("Service Unavailable", status=503)
          if instructions.endswith("/retry-2"):
              print("## Return error for retry 2")
              return flask.Response("Service Unavailable", status=503)
          print("## Return success for %s" % instructions)
          return flask.Response(
              response_payload, status=200, headers=headers
          )
  
      response = flask.make_response(response_payload)
      length = len(response_payload)
      content_range = "bytes %d-%d/%d" % (begin, end - 1, length)
      response.headers["Content-Range"] = content_range
      response.headers["x-goog-hash"] = revision.x_goog_hash_header()
      response.headers["x-goog-generation"] = revision.generation
      return response
  
imports: import argparse
  import error_response
  import flask
  import gcs_bucket
  import gcs_object
  import json
  import os
  import re
  import testbench_utils
  import time
  import sys
  from werkzeug import serving
  from werkzeug.middleware.dispatcher import DispatcherMiddleware
label_desc: Use image node_id 17 for calling a global function with example usage: objects_get_common(bucket_name, object_name, revision) and returns: response, flask, flask, flask, flask, flask, flask, flask