Permalink
Browse files

retry on 302

  • Loading branch information...
1 parent 03df102 commit 89c3847d6229b15efa200cef078c8724efde6a20 @defunkt defunkt committed Dec 16, 2010
Showing with 6 additions and 4 deletions.
  1. +6 −4 evilbot.coffee
View
@@ -49,9 +49,9 @@ request = (method, path, body, callback) ->
body = JSON.stringify(body) if typeof(body) isnt 'string'
headers['Content-Length'] = body.length
- request = client.request(method, path, headers)
+ req = client.request(method, path, headers)
- request.on 'response', (response) ->
+ req.on 'response', (response) ->
if response.statusCode is 200
data = ''
response.setEncoding('utf8')
@@ -64,14 +64,16 @@ request = (method, path, body, callback) ->
catch e
body = data
callback body
+ else if response.statusCode is 302
+ request(method, path, body, callback)
else
console.log "#{response.statusCode}: #{path}"
response.setEncoding('utf8')
response.on 'data', (chunk) ->
console.log chunk
- request.write(body) if method is 'POST' and body
- request.end()
+ req.write(body) if method is 'POST' and body
+ req.end()
handlers = []

0 comments on commit 89c3847

Please sign in to comment.