Giter Site home page Giter Site logo

xd-synchttp's Introduction

xd-synchttp - a http library for node

Build Status

This is a synchronous http library for node.js. __It supports GET/POST request and focuses on high performance.

Install with:

npm install xd-synchttp

OS support

Linux-x64
Win32(x64/ia32)
MacOS(x64)

Usage Example

var sync = require("xd-synchttp");

var response_get = "";
var response_post = "";
var image_size = new Object();
var timeout = 3;
var post_data = {"field1":"1","field2":"2"};
var url = "http://www.baidu.com";
try{
	/*
	this is old function!
	response_get = sync.http_get(url,timeout);
	response_post = sync.http_post(url,post_data,timeout);
	*/
	//notify! you can call it by sync.sync_http(url);
	response_get = sync.sync_http(url,'get',{},timeout);
	response_post = sync.sync_http(url,'post',post_data,timeout);
	image_size = sync.get_image_size("http://wmod.66rpg.com/res/loading.gif");

}
catch(err){
	console.log(err);
}
console.log(response_get);
console.log(response_post);
console.log(image_size);

Note that the API is not support https.

Promises

not supported

API

"http_get"

you can use sync_http to instead of deprecated API

http_get(string,number);

http_get send a GET request

"http_post"

you can use sync_http to instead of deprecated API

http_post(string,object,number);

http_post send a POST request

"sync_http"

sync_http(string,string,object,number)

'sync_http' send a http request,support RESUFUL(get,post,delete,put,patch)

"get_image_size"

get_image_size(string);

get_image_size can get size of image from http or local file

How to Contribute

  • Open a pull request or an issue about what you want to implement / change. We're glad for any help!
  • Please be aware that we'll only accept fully tested code.

Contributors

The original author of xd-synchttp is Jing HAO

License

GPL

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.