Skip to content

Commit

Permalink
logging 'flushed' when we get a response from the endpoint and using …
Browse files Browse the repository at this point in the history
…hostname rather than host when we create the endpoint client
  • Loading branch information
thejefflarson committed Jul 7, 2010
1 parent 7ed32a5 commit 9d4e09b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/pixel-ping.js
Expand Up @@ -38,7 +38,9 @@
request = endpoint.request('POST', endParams.pathname, endHeaders);
request.write(data);
request.end();
return console.info('--- flushed ---');
return request.on('response', function(response) {
return console.info('--- flushed ---');
});
};
log = function(hash) {
var _b, _c, hits, key;
Expand Down Expand Up @@ -76,7 +78,7 @@
if (config.endpoint) {
console.info("Flushing hits to " + config.endpoint);
endParams = url.parse(config.endpoint);
endpoint = http.createClient(endParams.port || 80, endParams.host);
endpoint = http.createClient(endParams.port || 80, endParams.hostname);
endHeaders = {
host: endParams.host,
'Content-Type': 'application/x-www-form-urlencoded'
Expand Down
5 changes: 3 additions & 2 deletions src/pixel-ping.coffee
Expand Up @@ -32,7 +32,8 @@ flush: ->
request: endpoint.request 'POST', endParams.pathname, endHeaders
request.write data
request.end()
console.info '--- flushed ---'
request.on 'response', (response) ->
console.info '--- flushed ---'
# Log the contents of the hits to stdout.
log: (hash) ->
Expand Down Expand Up @@ -61,7 +62,7 @@ pixel: fs.readFileSync(__dirname + '/pixel.gif')
if config.endpoint
console.info "Flushing hits to $config.endpoint"
endParams: url.parse config.endpoint
endpoint: http.createClient endParams.port || 80, endParams.host
endpoint: http.createClient endParams.port || 80, endParams.hostname
endHeaders: {host : endParams.host, 'Content-Type': 'application/x-www-form-urlencoded'}

# Don't let exceptions kill the server.
Expand Down

0 comments on commit 9d4e09b

Please sign in to comment.