Creates a request packet.
@param {number} id Request id
@param {number} type Request type
@param {!Buffer} body Request data
@returns {!Buffer}
972989
function pack(id, type, body) {
    var buf = new Buffer(body.length + 14);
    buf.writeInt32LE(body.length + 10, 0);
    buf.writeInt32LE(id, 4);
    buf.writeInt32LE(type, 8);
    body.copy(buf, 12);
    buf[buf.length-2] = 0;
    buf[buf.length-1] = 0;
    return buf;
}
402756
function ObjectID(id) {
  // Duck-typing to support ObjectId from different npm packages
  if (id instanceof ObjectID) return id;
  if (!(this instanceof ObjectID)) return new ObjectID(id);

  this._bsontype = 'ObjectID';

  // The most common usecase (blank id, new objectId instance)
  if (id == null || typeof id === 'number') {
    // Generate a new id
    this.id = this.generate(id);
    // If we are caching the hex string
    if (ObjectID.cacheHexString) this.__id = this.toString('hex');
    // Return the object
    return;
  }

  // Check if the passed in id is valid
  var valid = ObjectID.isValid(id);

  // Throw an error if it's not a valid setup
  if (!valid && id != null) {
    throw new Error(
      'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'
    );
  } else if (valid && typeof id === 'string' && id.length === 24 && hasBufferType) {
    return new ObjectID(new Buffer(id, 'hex'));
  } else if (valid && typeof id === 'string' && id.length === 24) {
    return ObjectID.createFromHexString(id);
  } else if (id != null && id.length === 12) {
    // assume 12 byte string
    this.id = id;
  } else if (id != null && id.toHexString) {
    // Duck-typing to support ObjectId from different npm packages
    return id;
  } else {
    throw new Error(
      'Argument passed in must be a single String of 12 bytes or a string of 24 hex characters'
    );
  }

  if (ObjectID.cacheHexString) this.__id = this.toString('hex');
}
10791
function createResponse(request, response, body){
  return {
    statusCode: response.statusCode,
    statusText: response.statusMessage,
    headers: response.headers,
    originalUrl: request.url,
    effectiveUrl: request.url,
    redirected: false,
    requestMethod: request.method,
    requestHeaders: request.headers,
    body: body,
    retries: 0,
    throttled: false
  };
}
668315
public Tree createPingPacket(String id) {
		FastBuildTree msg = new FastBuildTree(4);
		msg.putUnsafe("ver", PROTOCOL_VERSION);
		msg.putUnsafe("sender", nodeID);
		msg.putUnsafe("id", id);
		msg.putUnsafe("time", System.currentTimeMillis());
		return msg;
	}
360964
public ActionFuture<IndexResponse> sendDataAsync(
            Map<String, ?> source, String index, String type, String id) {
        return indexQueryAsync(buildIndexRequest(source, index, type, id));
    }
177332
public static Result newUpdateResultRequest(Type[] types, long id) {

        Result result = newResult(ResultConstants.UPDATE_RESULT);

        result.metaData = ResultMetaData.newUpdateResultMetaData(types);
        result.id       = id;

        result.navigator.add(new Object[]{});

        return result;
    }
1371252
function requestId(options){

    options = extend({}, DEFAULTS);

    return function requestIdMiddleware(req, res, next){

        let id = _getId(req, options);
        let attributeName = options.attributeName;

        // console.log('requestid', id);

        /*
         * Want to expose the genrated
         * id in the request and response
         */
        req[attributeName] = id;

        if(res.req) res.req[attributeName] = id;

        /*
         * We send a header with the required
         * id...
         */
        if(options.resHeader) {
            res.set(options.resHeader, id);
        }

        next();
    }
}
286160
def request_service(self, type, id=0):
        
        srvs = self.services_by_name.get(type)
        if not srvs:
            return

        ser = srvs[id]

        if not ser.system:
            ser.setup_system(self, id=id)
        return ser
753679
function Request_getRequestBody() {
        if (Type.isArray(this.body) && this.body.length > 0) {
            return Buffer.concat(this.body);
        }
        return this.body;
    }
102250
function Request(reqBytes){
  var parsed;
  var err

  try {
    parsed = types.Request.decode(reqBytes);
  } catch (e) {
    err = e;
  }


  //Check for request errors here
  if(err){
    this.BadRequest = true;
    this.errCode = types.CodeType.EncodingError;
    this.errMsg = "The request failed to be decoded"
  } else if(!types.methodLookup[parsed.type]){
    //Request type not recognized
    //Make a request object for the error
    this.BadRequest = true;
    this.errCode = types.CodeType.UnknownRequest;
    this.errMsg = "The request type was not understood"
  } else {

    this.BadRequest = false; 
    this.type = parsed.type;
    this.method = types.methodLookup[this.type];
    this.data = parsed.data.buffer.slice(parsed.data.offset);
    this.dataLength = parsed.data.limit - parsed.data.offset;
    this.dataLittle = parsed.data.littleEndian;
    this.key = parsed.key;
    this.value = parsed.value;
  }
}
406608
function create_request_function(personality, doc_type,
				 id_field, label_field, link_type){

    return function(request, query) {

	// Declare a delayed response.
	var response = new Deferred();
	//response.wait(5000); // 5s wait for resolution

	// New agent on every call.
	var go = new bbop.golr.manager.ringo(server_loc, gconf);
	go.set_personality(personality); // profile in gconf
	go.add_query_filter('document_category', doc_type);
	
	// Define what we do when our GOlr (async) information
	// comes back within the scope of the deferred response
	// variable.
	function golr_callback_action(resp){

	    // Return caches for the values we'll collect.
	    var ret_terms = [];
	    var ret_descs = [];
	    var ret_links = [];

	    // Gather document info if available.
	    //var found_docs = resp.documents();		
	    bbop.core.each(resp.documents(),
			   function(doc){
			       var id = doc[id_field];
			       var label = doc[label_field];

			       ret_terms.push(label);
			       ret_descs.push(id);
			       ret_links.push(linker.url(id, link_type));
			   });

	    // Assemble final answer into the OpenSearch JSON
	    // form.
	    var ret_body = [query];
	    ret_body.push(ret_terms);
	    ret_body.push(ret_descs);
	    ret_body.push(ret_links);
	    var ans = {
		status: 200,
		headers: {'Content-Type': 'application/json'},
		body: [bbop.core.to_string(ret_body)]
	    };
	    response.resolve(ans);
	}

	// Run the agent action.
	//go.set_query(query);
	go.set_comfy_query(query);
	go.register('search', 'do', golr_callback_action);
	go.update('search');

	return response.promise;
    };
}
899969
private ObjectNode internalCreateRequest(String methodName, Object arguments, String id) {
		final ObjectNode request = mapper.createObjectNode();
		addId(id, request);
		addProtocolAndMethod(methodName, request);
		addParameters(arguments, request);
		addAdditionalHeaders(request);
		notifyBeforeRequestListener(request);
		return request;
	}
1225430
function getXhrOrXdr(id, suppliedXhr) {
        var xhrOrXdr = requestData[id] && requestData[id].xhr;

        if (!xhrOrXdr) {
            if (suppliedXhr) {
                xhrOrXdr = suppliedXhr;
            }
            else {
                if (options.cors.expected) {
                    xhrOrXdr = getCorsAjaxTransport();
                }
                else {
                    xhrOrXdr = qq.createXhrInstance();
                }
            }

            requestData[id].xhr = xhrOrXdr;
        }

        return xhrOrXdr;
    }
1163149
function(type, id) {
        var node = document.createElementNS(this.xmlns, type);
        if (id) {
            node.setAttributeNS(null, "id", id);
        }
        return node;    
    }
736353
function idSearch( id, type, callback ) {
    if ( ! endpoints['id'].hasOwnProperty(type) ) {
        return callback(new Error('No valid type'));
    }

    var url = apiBaseUrl+endpoints['id'][type] + id;

    fetch(url, function(result) {
        callback(result);
    });
}
956063
function details(id) {
  return new Promise((resolve, reject) => {
    if (!id || id === '') throw new Error('id cannot be blank');

    const options = {
      method: 'GET',
      hostname: 'www.exploitalert.com',
      port: null,
      path: `/view-details.html?id=${id}`,
      headers: {},
    };

    const req = http.request(options, (res) => {
      const chunks = [];

      res.on('data', (chunk) => {
        chunks.push(chunk);
      });

      res.on('end', () => {
        const body = Buffer.concat(chunks);
        resolve(body.toString());
      });
    });
    req.on('error', reject);
    req.end();
  })
    .then((html) => {
      const $ = cheerio.load(html);
      return $('pre').text();
    })
    .catch(err => err);
}
1187856
function(id, filename, responseType){
    	return $http({
        method: 'GET',
        url: '/dataprovider/' + id + '/' + encodeURIComponent(filename),
        responseType: responseType
      });
    }