Read more

RestClient sends XML Accept header by default

Thomas Eisenbarth
February 20, 2012Software engineer at makandra GmbH

REST Client Show archive.org snapshot is a nice, simple HTTP client library for Ruby.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

When you do a simple GET request like that:

RestClient.get 'http://example.com/'

it will result in this request beeing sent to www.example.com:

GET / HTTP/1.1
Accept: */*; q=0.5, application/xml
Accept-Encoding: gzip, deflate
Host: www.example.com

The application/xml accept header might lead to unexpected results on your server. You can force REST Client to ask the server for default text/html that way:

RestClient.get(site, {:accept => :html})
Posted by Thomas Eisenbarth to makandra dev (2012-02-20 11:01)