Skip to content

Instantly share code, notes, and snippets.

@baoblackcoal
Created March 21, 2016 09:56
Show Gist options
  • Save baoblackcoal/0134129d24cbe02615e9 to your computer and use it in GitHub Desktop.
Save baoblackcoal/0134129d24cbe02615e9 to your computer and use it in GitHub Desktop.
download ota fireware full request
GET /file HTTP/1.0
Host: 192.168.123.1:3001
Connection: keep-alive
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
Accept: */*
Authorization: token
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh-CN,zh;q=0.8
HEAD /file HTTP/1.0
Host: 192.168.123.1:3001
Connection: close
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
Accept: */*
@baoblackcoal
Copy link
Author

nodejs code

router.head('/file', function(req, res, next) {
  //res.send('file');
  console.log('file head');
  res.setHeader("Content-Length", 303700);
  next();
});

router.get('/file', function(req, res, next) {
  console.log('file download');
  var file = __dirname + '/user2.4096.new.4.bin';//'/app.js';
  res.download(file); // Set disposition and send it.

  console.log('file download finish');
});

cosole log

HEAD /file - - ms - -
file head
file download
file download finish
file download
file download finish

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment