MCPcopy Index your code
hub / github.com/totaljs/framework / request_response

Function request_response

utils.js:960–1108  ·  view source on GitHub ↗
(res)

Source from the content-addressed store, hash-verified

958}
959
960function request_response(res) {
961
962 var options = this.$options;
963 var uri = this.$uri;
964
965 res._buffer = null;
966 res._bufferlength = 0;
967
968 // We have redirect
969 if (res.statusCode === 301 || res.statusCode === 302) {
970
971 if (options.noredirect) {
972
973 options.timeoutid && clearTimeout(options.timeoutid);
974 options.canceled = true;
975
976 if (options.callback) {
977 options.callback(null, '', res.statusCode, res.headers, uri.host, EMPTYOBJECT, options.param);
978 options.callback = null;
979 }
980
981 if (options.evt) {
982 options.evt.removeAllListeners();
983 options.evt = null;
984 }
985
986 res.req.removeAllListeners();
987 res.removeAllListeners();
988 res.req = null;
989 res = null;
990 return;
991 }
992
993 if (options.redirect > 3) {
994
995 options.timeoutid && clearTimeout(options.timeoutid);
996 options.canceled = true;
997
998 if (options.callback) {
999 options.callback(new Error('Too many redirects.'), '', 0, undefined, uri.host, EMPTYOBJECT, options.param);
1000 options.callback = null;
1001 }
1002
1003 if (options.evt) {
1004 options.evt.removeAllListeners();
1005 options.evt = null;
1006 }
1007
1008 res.req.removeAllListeners();
1009 res.removeAllListeners();
1010 res.req = null;
1011 res = null;
1012 return;
1013 }
1014
1015 options.redirect++;
1016
1017 var loc = res.headers['location'];

Callers

nothing calls this directly

Calls 1

request_callFunction · 0.85

Tested by

no test coverage detected