Return a HTTPStatus compliant headers attribute

        FIX: duplicate headers will collide terribly!
547207
def get_headers(self):
        

        headers = {'Content-Type': goldman.JSON_MIMETYPE}

        for error in self.errors:
            if 'headers' in error:
                headers.update(error['headers'])
        return headers
907267
def build_extra_headers(request, proxyMode, orgaMode, currentOrga):
    """"""

    things_to_add = {}

    # If in proxymode, add needed infos to headers
    if proxyMode:

        # User
        for prop in settings.PIAPI_USERDATA:
            if hasattr(request.user, prop):
                things_to_add['user_' + prop] = getattr(request.user, prop)

        # Orga
        if orgaMode:
            things_to_add['orga_pk'] = currentOrga.pk
            things_to_add['orga_name'] = currentOrga.name
            things_to_add['orga_codops'] = currentOrga.ebu_codops

        # General
        things_to_add['base_url'] = baseURI

    if request and hasattr(request, 'META'):
        if 'REMOTE_ADDR' in request.META:
            things_to_add['remote-addr'] = request.META['REMOTE_ADDR']

        if 'HTTP_X_FORWARDED_FOR' in request.META and getattr(settings, 'HONOR_X_FORWARDED_FOR'):
            things_to_add['remote-addr'] = request.META['HTTP_X_FORWARDED_FOR']

        for meta_header, dest_header in [('HTTP_IF_NONE_MATCH', 'If-None-Match'), ('HTTP_ORIGIN', 'Origin'), ('HTTP_ACCESS_CONtROL_REQUEST_METHOD', 'Access-Control-Request-Method'), ('HTTP_ACCESS_CONTROL_REQUEST_HEADERS', 'Access-Control-Request-Headers')]:
            if meta_header in request.META:
                things_to_add[dest_header] = request.META[meta_header]

    return things_to_add
473021
def _get(self, url,
             param_dict=None,
             securityHandler=None,
             additional_headers=None,
             handlers=None,
             proxy_url=None,
             proxy_port=None,
             compress=True,
             custom_handlers=None,
             out_folder=None,
             file_name=None):
        
        # ensure that no spaces are in the url
        url = url.replace(" ", "%20")

        pass_headers = {}
        if custom_handlers is None:
            custom_handlers = []
        if handlers is None:
            handlers = []
        if param_dict is None:
            param_dict = {}
        self._last_method = "GET"
        CHUNK = 4056
        param_dict, handler, cj = self._processHandler(securityHandler, param_dict)
        if additional_headers is not None:
            headers = [] + additional_headers
        else:
            headers = []
        pass_headers = {}
        if securityHandler and securityHandler.referer_url:
            pass_headers['referer'] = securityHandler.referer_url
        for h in headers:
            pass_headers[h[0]] = h[1]

        if compress:
            pass_headers['Accept-encoding'] = 'gzip'
        else:
            pass_headers['Accept-encoding'] = ""
        #headers.append(('User-Agent', USER_AGENT))
        pass_headers['User-Agent'] = self.useragent
        if len(param_dict.keys()) == 0:
            param_dict = None
        if handlers is None:
            handlers = []
        if handler is not None:
            handlers.append(handler)
        handlers.append(RedirectHandler())
        if self._verify == False and \
           sys.version_info[0:3] >= (2, 7, 9) and \
            hasattr(ssl,'create_default_context'):
            ctx = ssl.create_default_context()
            ctx.check_hostname = False
            ctx.verify_mode = ssl.CERT_NONE
            handlers.append(request.HTTPSHandler(context=ctx))
        if cj is not None:
            handlers.append(request.HTTPCookieProcessor(cj))
        if proxy_url is not None:
            if proxy_port is None:
                proxy_port = 80
            proxies = {"http":"http://%s:%s" % (proxy_url, proxy_port),
                       "https":"https://%s:%s" % (proxy_url, proxy_port)}
            proxy_support = request.ProxyHandler(proxies)
            handlers.append(proxy_support)
        opener = request.build_opener(*handlers)

        opener.addheaders = headers
        request.install_opener(opener)
        ctx = None
        hasContext = False
        if self._verify == False and \
           'context' in self._has_context(request.urlopen) and \
            sys.version_info[0:3] >= (2, 7, 9) and \
            hasattr(ssl,'create_default_context'):
            ctx = ssl.create_default_context()
            ctx.check_hostname = False
            ctx.verify_mode = ssl.CERT_NONE
            hasContext = True

        if hasContext == False:

            if param_dict is None:
                req = request.Request(self._asString(url),
                                      headers=pass_headers)
                resp = request.urlopen(req)
            elif len(str(urlencode(param_dict))) + len(url) >= 1999:
                return self._post(
                    url=url,
                    param_dict=param_dict,
                    files=None,
                    securityHandler=securityHandler,
                    additional_headers=additional_headers,
                    custom_handlers=custom_handlers,
                    proxy_url=proxy_url,
                    proxy_port=proxy_port,
                    compress=compress,
                    out_folder=out_folder,
                    file_name=file_name,
                    force_form_post=False)
            else:
                format_url = self._asString(url) + "?%s" % urlencode(param_dict)
                req = request.Request(format_url,
                                      headers=pass_headers)
                resp = request.urlopen(req)
        else:
            if param_dict is None:
                req = request.Request(self._asString(url),
                                      headers=pass_headers)
                resp = request.urlopen(req,
                                       context=ctx)
            elif len(str(urlencode(param_dict))) + len(url) >= 1999:
                return self._post(
                    url=url,
                    param_dict=param_dict,
                    files=None,
                    securityHandler=securityHandler,
                    additional_headers=additional_headers,
                    custom_handlers=custom_handlers,
                    proxy_url=proxy_url,
                    proxy_port=proxy_port,
                    compress=compress,
                    out_folder=out_folder,
                    file_name=file_name,
                    force_form_post=False)
            else:
                format_url = self._asString(url) + "?%s" % urlencode(param_dict)
                req = request.Request(format_url,
                                      headers=pass_headers)
                resp = request.urlopen(req,
                                       context=ctx)
        self._last_code = resp.getcode()
        self._last_url = resp.geturl()
        #  Get some headers from the response
        maintype = self._mainType(resp)
        contentDisposition = resp.headers.get('content-disposition')
        contentMD5 = resp.headers.get('Content-MD5')
        #contentEncoding = resp.headers.get('content-encoding')
        contentType = resp.headers.get('content-Type').split(';')[0].lower()
        contentLength = resp.headers.get('content-length')
        if maintype.lower() in ('image',
                                'application/x-zip-compressed') or \
           contentType in ('application/x-zip-compressed', 'application/octet-stream') or \
           contentMD5 is not None or\
           (contentDisposition is not None and \
            contentDisposition.lower().find('attachment;') > -1):

            fname = self._get_file_name(
                contentDisposition=contentDisposition,
                url=url)
            if out_folder is None:
                out_folder = tempfile.gettempdir()
            if contentLength is not None:
                max_length = int(contentLength)
                if max_length < CHUNK:
                    CHUNK = max_length
            file_name = os.path.join(out_folder, fname)
            with open(file_name, 'wb') as writer:
                for data in self._chunk(response=resp,
                                        size=CHUNK):
                    writer.write(data)
                    writer.flush()
                writer.flush()
                del writer
            return file_name
        else:
            read = ""
            for data in self._chunk(response=resp,
                                    size=CHUNK):
                if self.PY3 == True:
                    read += data.decode('utf-8')
                else:
                    read += data

                del data
            try:
                results = json.loads(read)
                if 'error' in results:
                    if 'message' in results['error']:
                        if results['error']['message'] == 'Request not made over ssl':
                            if url.startswith('http://'):
                                url = url.replace('http://', 'https://')
                                return self._get(url,
                                                 param_dict,
                                                 securityHandler,
                                                 additional_headers,
                                                 handlers,
                                                 proxy_url,
                                                 proxy_port,
                                                 compress,
                                                 custom_handlers,
                                                 out_folder,
                                                 file_name)
                return results
            except:
                return read
1051232
def _parse_request_headers(request: web.Request):
        
        headers = request.headers.get(hdrs.ACCESS_CONTROL_REQUEST_HEADERS)
        if headers is None:
            return frozenset()

        # FIXME: validate each header string, if parsing fails, raise
        # HTTPForbidden.
        # FIXME: check, that headers split and stripped correctly (according
        # to ABNF).
        headers = (h.strip(" \t").upper() for h in headers.split(","))
        # pylint: disable=bad-builtin
        return frozenset(filter(None, headers))
1006079
public IpcLogEntry withHttpStatus(int httpStatus) {
    if (httpStatus >= 100 && httpStatus < 600) {
      this.httpStatus = httpStatus;
      if (status == null) {
        status = IpcStatus.forHttpStatus(httpStatus);
      }
      if (result == null) {
        result = status.result();
      }
    } else {
      // If an invalid HTTP status code is passed in
      this.httpStatus = -1;
    }
    return this;
  }
987021
function setWriteHeadHeaders (statusCode) {
  var length = arguments.length
  var headerIndex = length > 1 && typeof arguments[1] === 'string'
    ? 2
    : 1

  var headers = length >= headerIndex + 1
    ? arguments[headerIndex]
    : undefined

  this.statusCode = statusCode

  if (Array.isArray(headers)) {
    // handle array case
    setHeadersFromArray(this, headers)
  } else if (headers) {
    // handle object case
    setHeadersFromObject(this, headers)
  }

  // copy leading arguments
  var args = new Array(Math.min(length, headerIndex))
  for (var i = 0; i < args.length; i++) {
    args[i] = arguments[i]
  }

  return args
}
1337128
def __check_http_err(self, status_code):
        """"""
        if status_code == 403:
            raise exceptions.APIAuthenticationError(self.api_key)
        elif status_code == 503:
            raise exceptions.APITimeoutError()
        else:
            return False
94181
function parseHttpHeaders(headers) {
    var meta = {};
    
    for (var headerName in headers) {
        var headerValue = headers[headerName];
        
        if (headerName=="x-ratelimit-limit") {
            meta.rateLimit = headerValue;
        } else if (headerName=="x-ratelimit-remaining") {
            meta.rateLimitRemaining = headerValue;
        } else if (headerName=="x-ratelimit-reset") {
            meta.rateLimitReset = headerValue;
        } else if (headerName=="link") {
            var regexp = /<(.+)>; rel=(.+),?/g;
            var match;
            do {
                match = regexp.exec(headerValue);
                if (match) {
                    var url = match[1];
                    var rel = match[2];
                    
                    var regexp2 = /[\?|&]page=(\d+)/;
                    var match2 = regexp2.exec(url);
                    if (match2) {
                        var page = match2[1];
                        if (rel=='prev') {
                            meta.prevPage = page;
                        } else if (rel=='next') {
                            meta.nextPage = page;
                        } else if (rel=='last') {
                            meta.lastPage = page;
                        }
                    }
                }
            } while (match);
        } 
    }
    
    return meta;
}
960902
def from_http(cls, headers: Mapping[str, str]) -> Optional["RateLimit"]:
        
        try:
            limit = int(headers["x-ratelimit-limit"])
            remaining = int(headers["x-ratelimit-remaining"])
            reset_epoch = float(headers["x-ratelimit-reset"])
        except KeyError:
            return None
        else:
            return cls(limit=limit, remaining=remaining, reset_epoch=reset_epoch)
514562
def canonical_headers(self):
        
        canonical_headers = ''

        for header in HEADERS:
            if header not in self.message:
                continue

            for value in self.message.get_all(header):
                canonical_value = self.canonical_header_value(header, value)
                if re.search(r'\S', canonical_value):
                    canonical_headers += '{}: {}\n'.format(
                        header, canonical_value)

        canonical_headers = canonical_headers.encode('utf-8')
        if len(canonical_headers) > 50:
            return canonical_headers

        # At this point we should have at absolute minimum 3 or 4 headers, e.g.
        # From/To/Date/Subject; if not, something went badly wrong.

        if len(canonical_headers) == 0:
            raise InsufficientHeadersError("No canonical headers found")

        err = textwrap.dedent("""\
            Not enough data from canonical headers to compute reliable hash!
            Headers:
            --------- 8< --------- 8< --------- 8< --------- 8< ---------
            {}
            --------- 8< --------- 8< --------- 8< --------- 8< ---------""")
        raise InsufficientHeadersError(err.format(canonical_headers))
367062
def _http_headers(self):
        
        if not self.usertag:
            return {}

        creds = u'{}:{}'.format(
            self.usertag,
            self.password or ''
        )
        token = base64.b64encode(creds.encode())
        return {
            'Authorization': 'Basic {}'.format(token.decode())
        }
200108
function (string) {
    if (!string || string === '' || string.indexOf('\r\n') === -1) {
      return {
        version: 'HTTP/1.1',
        statusText: ''
      }
    }

    var lines = string.split('\r\n')
    var status = lines.shift()

    // Remove empty strings
    lines = lines.filter(Boolean)

    // Parse status line
    var output = this.parseStartLine(status)

    // init headers object & array
    output.headersObj = {}
    output.headersArr = []

    // Parse headers
    var header
    for (var i = lines.length; i--;) {
      header = this.parseHeaderLine(lines[i])

      output.headersArr.push(header)
      output.headersObj[header.name] = header.value
    }

    return output
  }
1280938
def header_status(header):
    """"""
    status_line = header[:header.find('\r')]
    # 'HTTP/1.1 200 OK' -> (200, 'OK')
    fields = status_line.split(None, 2)
    return int(fields[1]), fields[2]
274293
def add_conditional_headers(req, opts)

      # if path is cached send since and/or match

      e = @cache[opts[:c_uri]]

      return unless e # not cached

      req['If-Modified-Since'] = e.lastmod if e.lastmod
      req['If-None-Match'] = e.etag if e.etag

      opts[:c_cached] = e
    end
942503
protected HttpStatus getHttpStatus(Map<String, Object> errorAttributes) {
		int statusCode = (int) errorAttributes.get("status");
		return HttpStatus.valueOf(statusCode);
	}
589545
function mergeAllowedClientHeaders({ headers, request }) {
  const prohibited = ['accept-encoding', 'connection', 'host', 'origin']
  request.headers = Object.entries(headers).reduce((memo, header) => {
    const [key, val] = header
    if (prohibited.indexOf(key) === -1) memo[key] = val // eslint-disable-line
    return memo
  }, request.headers)
  return request
}
610034
String debugGetAllHttpHdrs(HttpServletRequest req) {
        if (req == null)
            return null;
        StringBuffer sb = new StringBuffer(512);
        Enumeration<String> headerNames = req.getHeaderNames();
        while (headerNames != null && headerNames.hasMoreElements()) {
            String headerName = headerNames.nextElement();
            sb.append(headerName).append("=");
            sb.append("[").append(SRTServletRequestUtils.getHeader(req, headerName)).append("]\n");
        }
        return sb.toString();
    }