Skip to content

Commit

Permalink
Now supports HTTPS.
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf committed Dec 31, 2010
1 parent 7270e49 commit 587e537
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ zombie.js-changelog(7) -- Changelog
===================================


### Version 0.8.7 2010-12-31


### Version 0.8.6 2010-12-31

Now supports cookies on redirect (thanks [Łukasz
Expand All @@ -12,6 +15,8 @@ Handle server returning multiple `Set-Cookie` headers.
The `clickLink` and `pressButton` methods should always pass to callback
and not throw error directly.

Now supports HTTPS.

198 Tests
2.6 sec to complete

Expand Down
7 changes: 5 additions & 2 deletions src/zombie/history.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,21 @@ class History

# Make the actual request: called again when dealing with a redirect.
makeRequest = (url, method, data)=>
headers = { "User-Agent": browser.userAgent }
headers = { "user-agent": browser.userAgent }
browser.cookies(url.hostname, url.pathname).addHeader headers
if method == "GET" || method == "HEAD"
url.search = "?" + qs.stringify(data) if data
data = null
headers["content-length"] = 0
else
data = qs.stringify(data)
headers["content-type"] = enctype || "application/x-www-form-urlencoded"
headers["content-length"] = data.length

window.request { url: URL.format(url), method: method, headers: headers, body: data }, (done)=>
client = http.createClient(url.port || 80, url.hostname)
secure = url.protocol == "https:"
port = url.port || (if secure then 443 else 80)
client = http.createClient(port, url.hostname, secure)
path = "#{url.pathname || ""}#{url.search || ""}"
path = "/#{path}" unless path[0] == "/"
headers.host = url.host
Expand Down
7 changes: 5 additions & 2 deletions src/zombie/xhr.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ XMLHttpRequest = (browser, window)->
reset()

# Allow setting headers in this state.
headers = { "User-Agent": browser.userAgent }
headers = { "user-agent": browser.userAgent }
@setRequestHeader = (header, value)-> headers[header.toString().toLowerCase()] = value.toString()
# Allow calling send method.
@send = (data)->
Expand All @@ -60,13 +60,16 @@ XMLHttpRequest = (browser, window)->
makeRequest = (url, method, headers, data)=>
if method == "GET" || method == "HEAD"
data = null
headers["content-length"] = 0
else
headers["content-type"] ||= "text/plain;charset=UTF-8"
headers["content-length"] = data.length
browser.cookies(url.hostname, url.pathname).addHeader headers

window.request { url: URL.format(url), method: method, headers: headers, body: data }, (done)=>
client = http.createClient(url.port, url.hostname)
secure = url.protocol == "https:"
port = url.port || (if secure then 443 else 80)
client = http.createClient(port, url.hostname, secure)
path = "#{url.pathname || ""}#{url.search || ""}"
path = "/#{path}" unless path[0] == "/"
headers.host = url.host
Expand Down

0 comments on commit 587e537

Please sign in to comment.