Created
November 3, 2013 16:59
-
-
Save cb372/7292307 to your computer and use it in GitHub Desktop.
Trying to reproduce problem with file downloads using CasperJS. Failed to reproduce problem - User Agent and cookies are sent as expected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note: Add a line to /etc/hosts before running. | |
// 127.0.0.1 www.oracle.com download.oracle.com | |
var casper = require('casper').create(); | |
casper.userAgent('Custom user agent'); | |
casper.start('http://www.oracle.com:4567/', function() { | |
this.echo('Opened page at /'); | |
}); | |
casper.then(function() { | |
this.download('http://download.oracle.com:4567/download', 'response.txt'); | |
}); | |
casper.run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
get '/' do | |
response.set_cookie('my_cookie', :value => 'asdf',:domain => '.oracle.com') | |
"Hello" | |
end | |
get '/download' do | |
headers = request.env.select {|k,v| k.start_with? 'HTTP_'} | |
.collect {|pair| [pair[0].sub(/^HTTP_/, ''), pair[1]]} | |
.collect {|pair| pair.join(": ") << "\n"} | |
.sort | |
.join("\n") | |
"Here are your request headers.\n\n" + headers | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment