Zum Hauptteil springen

Klasse: IncomingMessage

Klasse: IncomingMessage

Behandelt Antworten zu HTTP/HTTPS Anfragen.

Prozess: Main, Utility
Diese Klasse wird nicht aus dem 'electron'-Modul exportiert. Es ist nur als Rückgabewert anderer Methoden in der Electron-API verfügbar.

IncomingMessage implementiert das Readable Stream interface und ist somit ein EventEmitter.


Event: 'data'

Kehrt zurück:

  • chunk Buffer - Ein Stück der Antwortdaten.

Das data Event ist die gewöhnliche Methode um Antwortdaten in Anwendungscode zu transferieren.

Event: 'end'

Gibt an dass der Body der Antwort endet. Must be placed before 'data' event.

Event: 'aborted'

Ausgegeben wenn eine Anfrage während einer laufenden HTTP Transaktion abgebrochen wurde.

Event: 'error'

Kehrt zurück:

error Error - Typically holds an error string identifying failure root cause.

Emitted when an error was encountered while streaming response data events. For instance, if the server closes the underlying while the response is still streaming, an error event will be emitted on the response object and a close event will subsequently follow on the request object.

Instanz Eigenschaften

An IncomingMessage instance has the following readable properties:


An Integer indicating the HTTP response status code.


A string representing the HTTP status message.


A Record<string, string | string[]> representing the HTTP response headers. The headers object is formatted as follows:

  • All header names are lowercased.
  • Duplicates of age, authorization, content-length, content-type, etag, expires, from, host, if-modified-since, if-unmodified-since, last-modified, location, max-forwards, proxy-authorization, referer, retry-after, server, or user-agent are discarded.
  • set-cookie is always an array. Duplicates are added to the array.
  • For duplicate cookie headers, the values are joined together with '; '.
  • For all other headers, the values are joined together with ', '.


A string indicating the HTTP protocol version number. Typical values are '1.0' or '1.1'. Additionally httpVersionMajor and httpVersionMinor are two Integer-valued readable properties that return respectively the HTTP major and minor version numbers.


An Integer indicating the HTTP protocol major version number.


An Integer indicating the HTTP protocol minor version number.


A string[] containing the raw HTTP response headers exactly as they were received. The keys and values are in the same list. It is not a list of tuples. So, the even-numbered offsets are key values, and the odd-numbered offsets are the associated values. Header names are not lowercased, and duplicates are not merged.

// Prints something like:
// [ 'user-agent',
// 'this is invalid because there can be only one',
// 'User-Agent',
// 'curl/7.22.0',
// 'Host',
// '',
// 'ACCEPT',
// '*/*' ]