From: Ryan Davis Date: 2012-10-05T16:33:22+09:00 Subject: Re: NET:HTTP headers ruby gem On Oct 4, 2012, at 23:43 , Shaban K. wrote: > I am trying to use the NET:HTTP gem to add an api-key to http header of > a client, but it just doesn't seem to be working for some reason when I > try and test it out.Basically the server requires the http header of the > client or anything to have http_x_api header in order to serve the > request. By "to http header of a client" I assume you mean to the request... > > res = Net::HTTP.start('localhost', port ) { |h| h.get('/')} ^^^ response ^^^^^^^^^^ request and everything below is response as well... > res.add_field('api-key', 'wow') > res.each_header do |key, value| > p "#{key} => #{value}" > end > puts (res.code == '200' && res.body == 'boo') ? 'OK' : 'FAIL'