Sets the Accept header to application/json.

@api private
190511
function setAcceptHeader(req) {
    var httpRequest = req.httpRequest;
    if (!httpRequest.headers.Accept) {
      httpRequest.headers['Accept'] = 'application/json';
    }
  }
22009
def set_header(self, header, value):
        
        # requests>=2.11 only accepts `str` or `bytes` header values
        # raising an exception here, instead of leaving it to `requests` makes
        # it easy to know where we passed a wrong header type in the code.
        if not isinstance(value, (str, bytes)):
            raise TypeError("header values must be str or bytes, but %s value has type %s" % (header, type(value)))
        self._headers[header] = value
89314
def post_json(self, uri, data, **kwargs):
        
        encoded_data = json.dumps(data)
        kwargs.setdefault("headers", {}).update({
            "Content-Type": "application/json",  # tell server we are sending json
        })
        return self.post(uri, data=encoded_data, **kwargs)
38140
def select_header_content_type(content_types)
      if content_types.empty?
        'application/json' # use application/json by default
      elsif content_types.any?{ |s| s.casecmp('application/json')==0 }
        'application/json' # use application/json if it's included
      else
        content_types[0] # otherwise, use the first one
      end
    end
595999
def put_json(self, url, data, cls=None, **kwargs):
        
        kwargs['data'] = to_json(data, cls=cls)
        kwargs['headers'] = self.default_headers
        return self.put(url, **kwargs).json()
676816
def set_header(self, key, value):
    
    self.conn.issue_command("Header", _normalize_header(key), value)
567705
function evalheaders(json, type) {
		var id = json.$originalid || json.$instanceid;
		delete json.$instanceid;
		delete json.$originalid;
		if (id) {
			Object.defineProperty(type, "$originalid", gui.Property.nonenumerable({
				value: id
			}));
		}
	}
757934
function _setResponseHeaders(headers) {
    this.responseHeaders = {};

    for (var header in headers) {
      if (headers.hasOwnProperty(header)) {
          this.responseHeaders[header] = headers[header];
      }
    }

    if (this.forceMimeType) {
      this.responseHeaders['Content-Type'] = this.forceMimeType;
    }

    if (this.async) {
      this._readyStateChange(FakeXMLHttpRequest.HEADERS_RECEIVED);
    } else {
      this.readyState = FakeXMLHttpRequest.HEADERS_RECEIVED;
    }
  }
873678
def _put_or_post_json(self, method, url, data):
        
        if self.parsed_endpoint.scheme == 'https':
            conn = httplib.HTTPSConnection(self.parsed_endpoint.netloc)
        else:
            conn = httplib.HTTPConnection(self.parsed_endpoint.netloc)
        head = {
            "Content-Type": "application/json",
            "Accept": "application/json",
            "User-Agent": USER_AGENT,
            API_TOKEN_HEADER_NAME: self.api_token,
        }
        if self.api_version in ['0.1', '0.01a']:
            head[API_VERSION_HEADER_NAME] = self.api_version
        conn.request(method, url, json.dumps(data), head)
        resp = conn.getresponse()
        self._handle_response_errors(method, url, resp)
        return json.loads(resp.read())
10442
function(name, value) {
    var header = { raw: value };
    this.headers[Utils.headerize(name)] = [header];
  }
276025
protected function setJSONPayload($vars) {
    $this->headers['Content-Type'] = 'application/json';
    $this->headers['Content-Length'] = 0;
    $this->headers['Expect'] = '';

    if (!empty($vars)) {
      $data = json_encode($vars);
      $this->headers['Content-Length'] = strlen($data);
      curl_setopt($this->request, CURLOPT_POSTFIELDS, $data);
    }
  }
102115
public Request accept(String headerValue){
        final String accept = RequestHeaderFields.ACCEPT.getName();
        String acceptValue = headers.get(accept);
        if (acceptValue == null){
            acceptValue = headerValue;
        } else {
            acceptValue = acceptValue + ", " + headerValue;
        }
        return this.setHeader(accept, acceptValue);
    }
112903
public function setRequestFormatByAcceptHeader(JoinPointInterface $joinPoint)
    {

        /** @var \Neos\Flow\Mvc\ActionRequest $actionRequest */
        $actionRequest = $joinPoint->getProxy();

        /**
         * The Accept header should be the only one to determine which resulting
         * data format the client is able to understand. But since some JS libs
         * do send Accept XML but Content-Type Json even when the expect to process
         * jsonapi.org format data we care about both, the Accept header as well
         * as the Content-Type header.
         */
        foreach (array('Accept', 'Http-Accept', 'Content-Type') as $fieldName) {
            $headerValue = $actionRequest->getHttpRequest()->getHeader($fieldName);
            foreach (array('application/json', 'application/vnd.api+json') as $acceptableValue) {
                if (strpos($headerValue, $acceptableValue) !== false) {
                    $actionRequest->setFormat('json');

                    return;
                }
            }
        }
    }
60013
def get_headers(self):
        """"""
        headers = {
            "User-Agent": self.http_agent,
            "Content-Type": "application/json",
            "Accept": "application/json"
        }
        if self.headers:
            headers.update(self.headers)

        return headers
40621
def _set_default_headers(self):
        
        self.headers.setdefault('Date', self.get_current_time)
        self.headers.setdefault('Server', self.SERVER_INFO)
        self.headers.setdefault('Content-Length', "%d" % len(self.message))
        if self.app.enabled('x-powered-by'):
            self.headers.setdefault('X-Powered-By', 'Growler')
628432
def requires_application_json(f):
    """"""

    @functools.wraps(f)
    def wrapped(*args, **kwargs):
        from flask import request
        if request.get_json(silent=True) is None:
            er = ErrorResponse(description='Improper Content-Type header. Expecting "application/json"')
            return to_json_response(er), HTTPStatus.BAD_REQUEST
        else:
            return f(*args, **kwargs)

    return wrapped
698218
def stringify_headers headers
      headers.inject({}) do |result, (key, value)|
        if key.is_a? Symbol
          key = key.to_s.split(/_/).map { |w| w.capitalize }.join('-')
        end
        if 'CONTENT-TYPE' == key.upcase
          target_value = value.to_s
          result[key] = MIME::Types.type_for_extension target_value
        elsif 'ACCEPT' == key.upcase
          # Accept can be composed of several comma-separated values
          if value.is_a? Array
            target_values = value
          else
            target_values = value.to_s.split ','
          end
          result[key] = target_values.map { |ext| MIME::Types.type_for_extension(ext.to_s.strip) }.join(', ')
        else
          result[key] = value.to_s
        end
        result
      end
    end