Overview

Packages

  • Requests
    • Authentication
    • Cookies
    • Proxy
    • Session
    • Transport
    • Utilities

Classes

  • Requests_Hooks
  • Requests_IDNAEncoder
  • Requests_IPv6
  • Requests_IRI
  • Requests_SSL
  • Requests_Utility_CaseInsensitiveDictionary
  • Requests_Utility_FilteredIterator

Interfaces

  • Requests_Hooker
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated

Warning! You are currently reading the documentation for Requests 1.x.

It is recommended to upgrade to Requests 2.x at your earliest convenience. Upgrading to Requests 2.x is fairly straight-forward.
A full list of the changes can be found in the Changelog.

Visit the documentation for Requests_IDNAEncoder in Requests 2.x.

Class Requests_IDNAEncoder

IDNA URL encoder

Note: Not fully compliant, as nameprep does nothing yet.

Package: Requests\Utilities
See: https://tools.ietf.org/html/rfc3490 IDNA specification
See: https://tools.ietf.org/html/rfc3492 Punycode/Bootstrap specification
Located at Requests/IDNAEncoder.php
Methods summary
public static string
# encode( string $string )

Encode a hostname using Punycode

Encode a hostname using Punycode

Parameters

$string
Hostname

Returns

string
Punycode-encoded hostname
public static string
# to_ascii( string $string )

Convert a UTF-8 string to an ASCII string using Punycode

Convert a UTF-8 string to an ASCII string using Punycode

Parameters

$string
ASCII or UTF-8 string (max length 64 characters)

Returns

string
ASCII string

Throws

Requests_Exception
Provided string longer than 64 ASCII characters (idna.provided_too_long)
Requests_Exception
Prepared string longer than 64 ASCII characters (idna.prepared_too_long)
Requests_Exception
Provided string already begins with xn-- (idna.provided_is_prefixed)
Requests_Exception
Encoded string longer than 64 ASCII characters (idna.encoded_too_long)
protected static boolean
# is_ascii( string $string )

Check whether a given string contains only ASCII characters

Check whether a given string contains only ASCII characters

Parameters

$string

Returns

boolean
Is the string ASCII-only?

Internal

(Testing found regex was the fastest implementation)
protected static string
# nameprep( string $string )

Prepare a string for use as an IDNA name

Prepare a string for use as an IDNA name

Parameters

$string

Returns

string
Prepared string
protected static array
# utf8_to_codepoints( string $input )

Convert a UTF-8 string to a UCS-4 codepoint array

Convert a UTF-8 string to a UCS-4 codepoint array

Based on Requests_IRI::replace_invalid_with_pct_encoding()

Parameters

$input

Returns

array
Unicode code points

Throws

Requests_Exception
Invalid UTF-8 codepoint (idna.invalidcodepoint)
public static string
# punycode_encode( string $input )

RFC3492-compliant encoder

RFC3492-compliant encoder

Parameters

$input
UTF-8 encoded string to encode

Returns

string
Punycode-encoded string

Throws

Requests_Exception
On character outside of the domain (never happens with Punycode) (idna.character_outside_domain)

Internal

Pseudo-code from Section 6.3 is commented with "#" next to relevant code
protected static string
# digit_to_char( integer $digit )

Convert a digit to its respective character

Convert a digit to its respective character

Parameters

$digit
Digit in the range 0-35

Returns

string
Single character corresponding to digit

Throws

Requests_Exception
On invalid digit (idna.invalid_digit)

See

https://tools.ietf.org/html/rfc3492#section-5
protected static integer
# adapt( integer $delta, integer $numpoints, boolean $firsttime )

Adapt the bias

Adapt the bias

Parameters

$delta
$numpoints
$firsttime

Returns

integer

New bias

function adapt(delta,numpoints,firsttime):

See

https://tools.ietf.org/html/rfc3492#section-6.1
Constants summary
string ACE_PREFIX

ACE prefix used for IDNA

ACE prefix used for IDNA

See

https://tools.ietf.org/html/rfc3490#section-5
# 'xn--'
integer BOOTSTRAP_BASE

Bootstrap constant for Punycode

Bootstrap constant for Punycode

See

https://tools.ietf.org/html/rfc3492#section-5
# 36
integer BOOTSTRAP_TMIN

See

https://tools.ietf.org/html/rfc3492#section-5
# 1
integer BOOTSTRAP_TMAX

See

https://tools.ietf.org/html/rfc3492#section-5
# 26
integer BOOTSTRAP_SKEW

See

https://tools.ietf.org/html/rfc3492#section-5
# 38
integer BOOTSTRAP_DAMP

See

https://tools.ietf.org/html/rfc3492#section-5
# 700
integer BOOTSTRAP_INITIAL_BIAS

See

https://tools.ietf.org/html/rfc3492#section-5
# 72
integer BOOTSTRAP_INITIAL_N

See

https://tools.ietf.org/html/rfc3492#section-5
# 128
Requests 1.8.1 API Documentation API documentation generated by ApiGen