Node.js HTTP Modülü

❮ Dahili Modüller


Örnek

Bilgisayarınızın 8080 numaralı bağlantı noktasını dinleyen bir sunucu oluşturun.

8080 numaralı bağlantı noktasına erişildiğinde, "Merhaba Dünya!" yazın. cevap olarak geri:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.write('Hello World!');
  res.end();
}).listen(8080);

Tanım ve Kullanım

HTTP modülü, Node.js'nin HTTP (Köprü Metni Aktarım Protokolü) üzerinden veri aktarımı yapmasının bir yolunu sağlar.


Sözdizimi

Uygulamanıza HTTP modülünü dahil etmek için sözdizimi:

var http = require('http');

HTTP Özellikleri ve Yöntemleri

Method Description
createClient() Deprecated. Creates a HTTP client
createServer() Creates an HTTP server
get() Sets the method to GET, and returns an object containing the user's request
globalAgent Returns the HTTP Agent
request() Returns an object containing the user's request

❮ Dahili Modüller