1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00

Add an example about International domain names (#669)

Solution to non-ASCII character problem
This commit is contained in:
Ferdinando Traversa 2021-06-04 08:01:46 +02:00 committed by GitHub
parent 9ca514d672
commit 868053fce7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View file

@ -48,7 +48,6 @@ puts stack_exchange.users
```
See the [examples directory](http://github.com/jnunemaker/httparty/tree/master/examples) for even more goodies.
## Command Line Interface
httparty also includes the executable `httparty` which can be

View file

@ -84,3 +84,6 @@
* [Accessing x509 Peer Certificate](peer_cert.rb)
* Provides access to the server's TLS certificate
* [Accessing IDNs](idn.rb)
* Uses a `get` request with an International domain names, which are Urls with emojis and non-ASCII characters such as accented letters.

10
examples/idn.rb Normal file
View file

@ -0,0 +1,10 @@
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'httparty')
require 'pp'
class Idn
include HTTParty
uri_adapter Addressable::URI
end
pp Idn.get("https://i❤.ws/emojidomain/💎?format=json")