Skip to content

Commit

Permalink
Update w3c_validation.rb
Browse files Browse the repository at this point in the history
fix for w3c blocking http requests without a user-agent
changed the way the http post is sent to w3c so that it includes a user-agent
aussiecoder-ash committed Jul 24, 2013
1 parent 2b85674 commit 744b8e6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions commands/w3c_validation.rb
Original file line number Diff line number Diff line change
@@ -14,8 +14,18 @@

require 'net/http'
require 'uri'

response = Net::HTTP.post_form(URI.parse(w3c_url), {'ss' => "1", 'fragment' => page})

#fix for w3c blocking http requests without a user-agent
#changed the way the http post is sent to w3c so that it includes a user-agent

uri = URI(w3c_url)
req = Net::HTTP::Post.new(uri.path)
req.set_form_data({'ss' => "1", 'fragment' => page})
req['User-Agent'] = 'Aptana'

response = Net::HTTP.start(uri.host, uri.port) do |http|
http.request(req)
end
status = response['x-w3c-validator-status']

content = response.body

0 comments on commit 744b8e6

Please sign in to comment.