Function to process and execute a payload buffer and return the response buffer
545858
function(functions, payload, error) {
		var payloadLength = payload.readUInt32LE(0);
		var identifierEndPosition = 8 + payload.readUInt32LE(4);
		var identifier = payload.slice(8, identifierEndPosition).toString(module.exports.encoding);
		
		var position = identifierEndPosition;
		
		var response = [ new Buffer(1) /* Status code response */ ];
		if(identifier in functions) {
			var args = [];
			for(; position < payloadLength;) {
				var dataType = payload.readUInt8(position++);
				var dataSize = payload.readUInt32LE(position);
				position += 4;
				var value = undefined;
				switch(dataType) {
					case module.exports.EnumDataType.byte:
						value = payload.readInt8(position);
						position++;
						break;
					case module.exports.EnumDataType.ubyte:
						value = payload.readUInt8(position);
						position++;
						break;
					case module.exports.EnumDataType.short:
						value = payload.readInt16LE(position);
						position += 2;
						break;
					case module.exports.EnumDataType.ushort:
						value = payload.readUInt16LE(position);
						position += 2;
						break;
					case module.exports.EnumDataType.int:
						value = payload.readInt32LE(position);
						position += 4;
						break;
					case module.exports.EnumDataType.uint:
						value = payload.readUInt32LE(position);
						position += 4;
						break;
					case module.exports.EnumDataType.float:
						value = payload.readFloatLE(position);
						position += 4;
						break;
					case module.exports.EnumDataType.double:
						value = payload.readDoubleLE(position);
						position += 8;
						break;
					case module.exports.EnumDataType.string:
						var next = position + dataSize;
						value = payload.slice(position, next).toString(module.exports.encoding);
						position = next;
						break;
					case module.exports.EnumDataType.boolean:
						value = payload.readUInt8(position) > 0;
						position++;
						break;
					case module.exports.EnumDataType.undefined:
						value = undefined;
						break;
					case module.exports.EnumDataType.null:
						value = null;
						break;
					default:
						error(new Error('Unsupported data type argument received from client'));
						response[0].writeUInt8(module.exports.EnumNodeResponse.NodeError, 0);
						return response[0]; // Early exit
				}
				
				args.push(value);
			}
	
			var result = functions[identifier].callback.apply(this, args);
			if(result === undefined) {
				// TODO: Will be removed in future versions. This response type is now handled
				// in the "Okay" response as the "undefined" datatype.
				response[0].writeUInt8(module.exports.EnumNodeResponse.NoResult, 0);
			}
			else {
				response[0].writeUInt8(module.exports.EnumNodeResponse.Okay, 0);
				
				var argtype = functions[identifier].responseType;
				
				if(!argtype) {
					if(result === null) {
						argtype = 'null';
					}
					else {
						switch(typeof result) {
							case 'number':
								if(result === (result|0)) {
									argtype = 'int'; // Default to int for normal numbers
								}
								else {
									argtype = 'float'; // float for anything else
								}
								break;
							case 'string':
								argtype = 'string';
								break;
							case 'boolean':
								argtype = 'boolean';
								break;
							case 'undefined':
								argtype = 'undefiend';
								break;
						}
					}
					functions[identifier].responseType = argtype;
				}
				
				var tempBuf = undefined;
				var dataType = module.exports.EnumDataType[argtype];
				if(dataType !== undefined) {
					switch(dataType) {
						case module.exports.EnumDataType.byte:
							tempBuf = new Buffer(1);
							tempBuf.writeInt8(result, 0);
							break;
						case module.exports.EnumDataType.ubyte:
							tempBuf = new Buffer(1);
							tempBuf.writeUInt8(result, 0);
							break;
						case module.exports.EnumDataType.short:
							tempBuf = new Buffer(2);
							tempBuf.writeInt16LE(result, 0);
							break;
						case module.exports.EnumDataType.ushort:
							tempBuf = new Buffer(2);
							tempBuf.writeUInt16LE(result, 0);
							break;
						case module.exports.EnumDataType.int:
							tempBuf = new Buffer(4);
							tempBuf.writeInt32LE(result, 0);
							break;
						case module.exports.EnumDataType.uint:
							tempBuf = new Buffer(4);
							tempBuf.writeUInt32LE(result, 0);
							break;
						case module.exports.EnumDataType.float:
							tempBuf = new Buffer(4);
							tempBuf.writeFloatLE(result, 0);
							break;
						case module.exports.EnumDataType.double:
							tempBuf = new Buffer(8);
							tempBuf.writeDoubleLE(result, 0);
							break;
						case module.exports.EnumDataType.string:
							tempBuf = new Buffer(result);
							break;
						case module.exports.EnumDataType.boolean:
							tempBuf = new Buffer(1);
							tempBuf.writeUInt8(result ? 0x1 : 0x0, 0);
							break;
						case module.exports.EnumDataType.undefined:
						case module.exports.EnumDataType.null:
							tempBuf = new Buffer(0);
							break;
						default:
							error(new Error('Data type' + dataType + ' has gone unhandled by this node implementation'));
							response[0].writeUInt8(module.exports.EnumNodeResponse.NodeError, 0);
							break;
					}
					
					if(dataType < module.exports.EnumDataType._max) {
						var argHeader = new Buffer(5);
						argHeader.writeUInt8(dataType, 0);
						argHeader.writeUInt32LE(tempBuf.length, 1);
						response.push(argHeader);
						response.push(tempBuf);
					}
				}
				else {
					error(new Error('Unsupported data type returned from nodesocket function'));
					response[0].writeUInt8(module.exports.EnumNodeResponse.NodeError, 0);
				}
			}
		}
		else {
			response[0].writeUInt8(module.exports.EnumNodeResponse.InvalidFunction, 0);
		}
	
		return makeBufferPosResponse(Buffer.concat(response), position);
	}
772084
function eval(req, res, source, args) {
  this.spawn();
  this.reply(req, res, this._limit);
  // need to coerce buffers for the moment
  args = args.map(function(a) {
    if(a instanceof Buffer) return a.toString();
    return a;
  })
  this.ps.send({event: 'eval', source: source, args: args});
}
360968
def feed_data(self, data):
        '''
        '''
        if self.buffer is None:
            self.buffer = bytearray(data)
        else:
            self.buffer.extend(data)
        data = self.buffer

        idx = data.find(self.separator)
        if idx >= 0:    # we have a full message
            idx += len(self.separator)
            data, rest = data[:idx], data[idx:]
            self.buffer = self.response(data, rest)
            self.event('post_request').fire()
            return rest
318839
def process_response(self, request, response):
        """"""

        # For debug only.
        if not settings.DEBUG:
            return response

        # Check for responses where the data can't be inserted.
        content_encoding = response.get('Content-Encoding', '')
        content_type = response.get('Content-Type', '').split(';')[0]
        if any((getattr(response, 'streaming', False),
                'gzip' in content_encoding,
                content_type not in _HTML_TYPES)):
            return response

        content = force_text(response.content, encoding=settings.DEFAULT_CHARSET)

        pattern = re.escape('</body>')
        bits = re.split(pattern, content, flags=re.IGNORECASE)

        if len(bits) > 1:
            bits[-2] += debug_payload(request, response, self.view_data)
            response.content = "</body>".join(bits)
            if response.get('Content-Length', None):
                response['Content-Length'] = len(response.content)

        return response
997581
def do_execute(self):
        
        fname = str(self.input.payload)
        spattern = str(self.resolve_option("regexp"))
        pattern = None
        if (spattern is not None) and (spattern != ".*"):
            pattern = re.compile(spattern)
        if (pattern is None) or (pattern.match(fname)):
            os.remove(fname)
        self._output.append(self.input)
        return None
980876
def make_response(status, headers, payload, environ):
    
    headers_dict = {}
    content_type = None
    for h in headers:
        if h[0].lower() == 'content-type':
            content_type = h[1]
        else:
            headers_dict[h[0]] = h[1]
    return HTTPResponse(body_bytes=payload, content_type=content_type,
                        status=int(status.split()[0]), headers=headers_dict)
544340
function asBuffer(data, encoding) {
    let result = data;
    if (!isNullOrUndefined(result)) {
        if ('object' !== typeof result) {
            // handle as string
            encoding = normalizeString(encoding);
            if (!encoding) {
                encoding = 'utf8';
            }
            result = new Buffer(toStringSafe(result), encoding);
        }
    }
    return result;
}
999668
def do_execute(self):
        
        if isinstance(self.input.payload, classes.JavaObject) and self.input.payload.is_serializable:
            copy = serialization.deepcopy(self.input.payload)
            if copy is not None:
                self._output.append(Token(copy))
        else:
            self._output.append(self.input)
        return None
948072
function afterProcessReq(request, response) {
    defaults.afterExecuteOfflineItem(response, request.payload);
    return processReqs(utils.storage.get('queue'));
  }
734429
function responseHandler (res, next) {
  return function (err, message) {
    if (err || !message) {
      next(err);
    } else {
      res.send(message);
    }
  }
}
793027
function onData(rawData){

        // strip delimiter sequence from array
        const input = rawData.toString(_encoding);

        // response data object - default no response data
        const data = {
            echo: input,
            response: null
        };

        // response found ? split echo and response
        const splitIndex = input.indexOf('\n');
        if (splitIndex > 0){
            data.echo = input.substr(0, splitIndex).trim();
            data.response = input.substr(splitIndex + 1).trim();
        }

        // process waiting for input ?
        if (_waitingForInput !== null){
            const resolver = _waitingForInput;
            _waitingForInput = null;
            resolver(data);
        }else{
            _inputbuffer.push(data);
        }
    }
81607
def processResponse(self, arg, replytype, **kw):
        
        if self.debug:
            log.msg('--->PROCESS REQUEST\n%s' %arg, debug=1)

        for h in self.handlers:
            arg.addCallback(h.processResponse, **kw)
            
        arg.addCallback(self.parseResponse, replytype)
983618
function handleUncompressed(res, _write, _end, callback) {
  let buffer = new BufferHelper();
  // Rewrite response method and get the content.
  res.write = data => buffer.concat(data);

  res.end = () => {
    let body;
    try {
      body = JSON.parse(buffer.toBuffer().toString());
    } catch (e) {
      body = buffer.toBuffer().toString();
      console.log('JSON.parse error:', e);
    }

    // Custom modified logic
    if (typeof callback === 'function') {
      body = callback(body);
    }

    let finish = _body => {
      // Converts the JSON to buffer.
      let body = new Buffer(JSON.stringify(_body));

      // Call the response method
      _write.call(res, body);
      _end.call(res);
    };

    if (body && body.then) {
      body.then(finish);
    } else {
      finish(body);
    }
  };
}
551593
ArgusResponse executeHttpRequest(RequestType requestType, String url, Object payload) throws IOException {
        url = _endpoint + url;

        String json = payload == null ? null : toJson(payload);

        return ArgusResponse.generateResponse(_doHttpRequest(requestType, url, json));
    }
1374586
function bufferFrom(data, enc) {
  if (typeof Buffer.from == 'function') {
    return Buffer.from(data, enc);
  } else {
    return new Buffer(data, enc);
  }
}
768665
private function outputBufferingHandlerMiddleware()
    {
        return function (ServerRequestInterface $request, DelegateInterface $delegate) {
            ob_start();
            try {
                $response = $delegate->process($request);
            } finally {
                ob_end_clean();
            }
            return $response;
        };
    }
1165544
def make_response(status, headers, payload, environ):
    
    return Response(body=payload, status=int(status.split()[0]),
                    headers=headers)