Permalink
Browse files

Now supports HTTPS.

  • Loading branch information...
1 parent 7270e49 commit 587e5370be0299d5489a277880d874b2fbe11084 @assaf assaf committed Dec 31, 2010
Showing with 15 additions and 4 deletions.
  1. +5 −0 CHANGELOG.md
  2. +5 −2 src/zombie/history.coffee
  3. +5 −2 src/zombie/xhr.coffee
View
@@ -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
@@ -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
@@ -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
View
@@ -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)->
@@ -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

0 comments on commit 587e537

Please sign in to comment.