Result of the form `(body, mime_type)`, or `ValueError`.
328044
def distributions_impl(self, tag, run):
    """"""
    (histograms, mime_type) = self._histograms_plugin.histograms_impl(
        tag, run, downsample_to=self.SAMPLE_SIZE)
    return ([self._compress(histogram) for histogram in histograms],
            mime_type)
1150978
def parse_mimetype(cls, value):
        '''
        '''
        match = re.match(r'([a-zA-Z0-9-]+/[a-zA-Z0-9-]+)', value)

        if match:
            return match.group(1)
1288318
def _simple_response_to_error_adapter(self, status, original_body):
        """"""
        body = original_body.copy()
        code = body.pop('code')
        title = body.pop('message')
        meta = body    # save whatever is left in the response

        e = [ErrorDetails(status, code, title)]

        return e, meta
211795
def errors
      if response.decoded_body
        response.decoded_body['errors'] ||
          response.decoded_body[:errors] ||
          response.decoded_body
      else
        response.body
      end
    end
270940
function(value) {
      if (!arguments.length) return mimeType;
      mimeType = value == null ? null : value + "";
      return request;
    }
665771
def mime_type(instance):
    
    mime_pattern = re.compile(r'^(application|audio|font|image|message|model'
                              '|multipart|text|video)/[a-zA-Z0-9.+_-]+')
    for key, obj in instance['objects'].items():
        if ('type' in obj and obj['type'] == 'file' and 'mime_type' in obj):
            if enums.media_types():
                if obj['mime_type'] not in enums.media_types():
                    yield JSONError("The 'mime_type' property of object '%s' "
                                    "('%s') should be an IANA registered MIME "
                                    "Type of the form 'type/subtype'."
                                    % (key, obj['mime_type']), instance['id'],
                                    'mime-type')
            else:
                info("Can't reach IANA website; using regex for mime types.")
                if not mime_pattern.match(obj['mime_type']):
                    yield JSONError("The 'mime_type' property of object '%s' "
                                    "('%s') should be an IANA MIME Type of the"
                                    " form 'type/subtype'."
                                    % (key, obj['mime_type']), instance['id'],
                                    'mime-type')
997365
function remakeBody (body, bodyType) {
  return blobUtil
    .base64StringToBlob(body)
    .then(function (blob) {
      switch (bodyType) {
        case BodyTypes.ARRAY_BUFFER:
          return blobUtil.blobToArrayBuffer(blob)
        case BodyTypes.BLOB:
          return blob
        case BodyTypes.FORM_DATA:
          throw new Error('Cannot make FormData from serialised Request')
        case BodyTypes.JSON:
          return blobToString(blob)
            .then(function (str) {
              return JSON.parse(str)
            })
        case BodyTypes.TEXT:
          return blobToString(blob)
        default:
          throw new Error('Unknown requested body type "' + bodyType + '"')
      }
    })
}
967885
def result_or_error(response):
    
    data = response.json()
    result = data.get('result')
    if result is not None:
        return result
    raise exceptions.ApiError(response, data)
390663
def body(self, value):
        """"""
        self.__body = value
        if value is not None:
            # Avoid calling len() which cannot exceed 4GiB in 32-bit python.
            body_length = getattr(
                self.__body, 'length', None) or len(self.__body)
            self.headers['content-length'] = str(body_length)
        else:
            self.headers.pop('content-length', None)
        # This line ensures we don't try to print large requests.
        if not isinstance(value, (type(None), six.string_types)):
            self.loggable_body = '<media body>'
693699
def result(body)
      begin
        ActiveSupport::JSON.decode body
      rescue => e
        {
          code: 502,
          msg: '内容解析错误',
          detail: e.to_s
        }
      end
    end
335189
def _ValidateReturnValue(return_value, type_check_dict):
  """"""
  return_check = type_check_dict.get("returns", None)
  if not return_check:
    return []

  messages = []
  if not _ValidateValue(return_value, return_check):
    message = ("Invalid return value '%s'. Expected %s" %
               (return_value, _FormatTypeCheck(return_check)))
    messages.append(message)
  return messages
552613
def get_mime_representation(self):
        """"""
        part = deepcopy(self.part)
        part.set_param('maxlinelen', '78', header='Content-Disposition')
        return part
1374558
def form_invalid(self, form):
        
        if self.request.is_ajax():
            return self.render_json_response(self.get_error_result(form))
        return super(AjaxFormMixin, self).form_invalid(form)
73940
def from_string(cls, value):
        """"""
        match = cls.pattern.search(value)
        if match is None:
            raise ValueError('"%s" is not a valid media type' % value)
        try:
            return cls(match.group('mime_type'), float(match.group('weight') or 1))
        except ValueError:
            return cls(value)
912624
def error_response(error_type="Internal server error",
                   error_text=None,
                   status=400,
                   participant=None):
    """"""
    traceback.print_exc()
    print("Error: {}.".format(error_type))

    page = error_page(
        error_text=error_text,
        error_type=error_type,
        participant=participant)

    data = {
        "status": "error",
        "html": page
    }
    return Response(dumps(data), status=status, mimetype='application/json')
874018
def parse(self, mimetypes):
        

        self._parse_top_level_content_type()

        link = 'tools.ietf.org/html/rfc2388'
        parts = cgi.FieldStorage(
            fp=self.req.stream,
            environ=self.req.env,
        )

        if not parts:
            self.fail('A payload in the body of your request is required '
                      '& must be encapsulated by the boundary with proper '
                      'headers according to RFC 2388', link)
        elif len(parts) > 1:
            self.fail('Currently, only 1 upload at a time is allowed. Please '
                      'break up your request into %s individual requests & '
                      'retry' % len(parts), link)
        else:
            self._parse_part(parts.list[0], mimetypes)
            return parts
10221
def validate_body!(response)
      return unless media_type
      return if media_type.kind_of? SimpleMediaType

      errors = self.media_type.validate(self.media_type.load(response.body))
      if errors.any?
        message = "Invalid response body for #{media_type.identifier}." +
          "Errors: #{errors.inspect}"
          raise Exceptions::Validation.new(message, errors: errors)
      end

    end