Appends key/val pairs to the end of a URL. Useful for passing arbitrary
    HTTP headers to XBMC to be used when fetching a media resource, e.g.
    cookies.
542866
def xbmc_url(url, **options):
    '''
    '''
    optionstring = urllib.urlencode(options)
    if optionstring:
        return url + '|' + optionstring
    return url
120732
function buildUploadURL(url, uuid, expiration, hmac, filename) {
  return url + '?uuid=' + uuid + '&expiration=' + expiration + '&hmac=' + hmac + '&file=' + filename;
}
897056
def wrap(http_method, url, params)
      params = params.merge(:appid => @appid)
      params[:sig] = Gateway.signature( "#{@appkey}&", Gateway.make_source(http_method.to_s.upcase, url, params) )
      params
    end
34104
function encode(cache, API_URL, obj) {
  if (!obj) return null;
  if (!obj.href) return obj;

  var href = API_URL ?
    pack(obj.href, API_URL) :
    obj.href;

  var cached = cache.get(href);
  if (cached) return cached;

  var encoded = base64.encode(new Buffer(href)).toString();
  cache.set(href, encoded);
  return encoded;
}
558478
def append_string(self, value):
        
        self._stream.append_var_uint32(len(value))
        self._stream.append_raw_bytes(value)
1337012
def _url_builder(url_root,api_key,path,params):
    
    params['api_key'] = api_key
    url_end = urlencode(params)
    url = "%s%s%s" % (url_root,path,url_end)
    return url
1049191
def append(self, offset, timestamp, key, value, headers,
               # Cache for LOAD_FAST opcodes
               encode_varint=encode_varint, size_of_varint=size_of_varint,
               get_type=type, type_int=int, time_time=time.time,
               byte_like=(bytes, bytearray, memoryview),
               bytearray_type=bytearray, len_func=len, zero_len_varint=1
               ):
        
        # Check types
        if get_type(offset) != type_int:
            raise TypeError(offset)
        if timestamp is None:
            timestamp = type_int(time_time() * 1000)
        elif get_type(timestamp) != type_int:
            raise TypeError(timestamp)
        if not (key is None or get_type(key) in byte_like):
            raise TypeError(
                "Not supported type for key: {}".format(type(key)))
        if not (value is None or get_type(value) in byte_like):
            raise TypeError(
                "Not supported type for value: {}".format(type(value)))

        # We will always add the first message, so those will be set
        if self._first_timestamp is None:
            self._first_timestamp = timestamp
            self._max_timestamp = timestamp
            timestamp_delta = 0
            first_message = 1
        else:
            timestamp_delta = timestamp - self._first_timestamp
            first_message = 0

        # We can't write record right away to out buffer, we need to
        # precompute the length as first value...
        message_buffer = bytearray_type(b"\x00")  # Attributes
        write_byte = message_buffer.append
        write = message_buffer.extend

        encode_varint(timestamp_delta, write_byte)
        # Base offset is always 0 on Produce
        encode_varint(offset, write_byte)

        if key is not None:
            encode_varint(len_func(key), write_byte)
            write(key)
        else:
            write_byte(zero_len_varint)

        if value is not None:
            encode_varint(len_func(value), write_byte)
            write(value)
        else:
            write_byte(zero_len_varint)

        encode_varint(len_func(headers), write_byte)

        for h_key, h_value in headers:
            h_key = h_key.encode("utf-8")
            encode_varint(len_func(h_key), write_byte)
            write(h_key)
            if h_value is not None:
                encode_varint(len_func(h_value), write_byte)
                write(h_value)
            else:
                write_byte(zero_len_varint)

        message_len = len_func(message_buffer)
        main_buffer = self._buffer

        required_size = message_len + size_of_varint(message_len)
        # Check if we can write this message
        if (required_size + len_func(main_buffer) > self._batch_size and
                not first_message):
            return None

        # Those should be updated after the length check
        if self._max_timestamp < timestamp:
            self._max_timestamp = timestamp
        self._num_records += 1
        self._last_offset = offset

        encode_varint(message_len, main_buffer.append)
        main_buffer.extend(message_buffer)

        return DefaultRecordMetadata(offset, required_size, timestamp)
449165
function (req) {
    var keys = Object.keys(req.headers)

    var values = keys.map(function (key) {
      return req.headers[key]
    })

    var headers = req.method + req.url + keys.join() + values.join()

    // startline: [method] [url] HTTP/1.1\r\n = 12
    // endline: \r\n = 2
    // every header + \r\n = * 2
    // add 2 for each combined header
    return new Buffer(headers).length + (keys.length * 2) + 2 + 12 + 2
  }
135574
function setURLParameter(url, key, value) {
  if(typeof url !== 'string') {
    throw new Error('URLs must be a string');
  }

  if(urlUtils) {
    //node.js
    url = urlUtils.parse(url);

    url.search = ((url.search) ? url.search + '&' : '?') + key + '=' + value;

    url = urlUtils.format(url);
  }
  else {
    //browser
    url = url.split('?');

    url[1] = ((url[1]) ? url[1] + '&' : '') + key + '=' + value;

    url = url.join('?');
  }

  return url;
}
1292652
private static void appendEscapedByte(StringBuilder builder, byte value) {
        builder.append('%');
        builder.append(HEX[(value >> 4) & 0x0f]);
        builder.append(HEX[value & 0x0f]);
    }
9755
def _encode_header(key: str, pdict: Dict[str, str]) -> str:
    
    if not pdict:
        return key
    out = [key]
    # Sort the parameters just to make it easy to test.
    for k, v in sorted(pdict.items()):
        if v is None:
            out.append(k)
        else:
            # TODO: quote if necessary.
            out.append("%s=%s" % (k, v))
    return "; ".join(out)
52629
def append_with_data(url, data):
        

        if data is None:
            return url

        url_parts = list(urlparse(url))

        query = OrderedDict(parse_qsl(url_parts[4], keep_blank_values=True))
        query.update(data)

        url_parts[4] = URLHelper.query_dict_to_string(query)

        return urlunparse(url_parts)
548164
private static void appendEncoded(StringBuilder sb, String value) {
        for (char ch : value.toCharArray()) {
            if (isUnreserved(ch)) sb.append(ch);
            else appendEscapedByte(sb, (byte) ch);
        }
    }
749451
public Query append(final String name, final String value) throws UnsupportedEncodingException {
        params.add(new Tuple<String, Tuple<String, String>>(name, new Tuple<String, String>(value, URLEncoder.encode(value, "UTF-8"))));
        return this;
    }
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
462949
private static void appendKeyValue(StringBuffer str, String key, String value) {

        str.append(key);
        if (value == IS_USED) {
            str.append(";");
        } else {
            str.append("=(");
            str.append(value);
            str.append(");");
        }
    }
890018
def append(self, timestamp, key, value, headers=[]):
        
        if self._closed:
            return None

        offset = self._next_offset
        metadata = self._builder.append(offset, timestamp, key, value, headers)
        # Return of None means there's no space to add a new message
        if metadata is None:
            return None

        self._next_offset += 1
        return metadata