| 
									
										
										
										
											2016-11-10 12:25:26 -08:00
										 |  |  | ## Class: IncomingMessage
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | > Handle responses to HTTP/HTTPS requests.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-23 11:20:56 -08:00
										 |  |  | Process: [Main](../glossary.md#main-process) | 
					
						
							| 
									
										
										
										
											2016-11-10 12:25:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | `IncomingMessage` implements the [Readable Stream](https://nodejs.org/api/stream.html#stream_readable_streams) | 
					
						
							| 
									
										
										
										
											2019-07-22 08:20:43 -07:00
										 |  |  | interface and is therefore an [EventEmitter][event-emitter]. | 
					
						
							| 
									
										
										
										
											2016-11-10 12:25:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | ### Instance Events
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #### Event: 'data'
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Returns: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | * `chunk` Buffer - A chunk of response body's data. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The `data` event is the usual method of transferring response data into | 
					
						
							|  |  |  | applicative code. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #### Event: 'end'
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Indicates that response body has ended. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #### Event: 'aborted'
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Emitted when a request has been canceled during an ongoing HTTP transaction. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #### Event: 'error'
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Returns: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | `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. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ### Instance Properties
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | An `IncomingMessage` instance has the following readable properties: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #### `response.statusCode`
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-24 10:29:03 +02:00
										 |  |  | An `Integer` indicating the HTTP response status code. | 
					
						
							| 
									
										
										
										
											2016-11-10 12:25:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #### `response.statusMessage`
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-24 10:29:03 +02:00
										 |  |  | A `String` representing the HTTP status message. | 
					
						
							| 
									
										
										
										
											2016-11-10 12:25:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #### `response.headers`
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-05 10:45:58 -07:00
										 |  |  | An `Record<string, string[]>` representing the response HTTP headers. The `headers` object is | 
					
						
							| 
									
										
										
										
											2016-11-10 12:25:26 -08:00
										 |  |  | formatted as follows: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | * All header names are lowercased. | 
					
						
							|  |  |  | * Each header name produces an array-valued property on the headers object. | 
					
						
							|  |  |  | * Each header value is pushed into the array associated with its header name. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #### `response.httpVersion`
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-24 10:29:03 +02:00
										 |  |  | A `String` indicating the HTTP protocol version number. Typical values are '1.0' | 
					
						
							| 
									
										
										
										
											2016-11-10 12:25:26 -08:00
										 |  |  | or '1.1'. Additionally `httpVersionMajor` and `httpVersionMinor` are two | 
					
						
							|  |  |  | Integer-valued readable properties that return respectively the HTTP major and | 
					
						
							|  |  |  | minor version numbers. | 
					
						
							| 
									
										
										
										
											2016-11-25 23:17:31 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | #### `response.httpVersionMajor`
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-24 10:29:03 +02:00
										 |  |  | An `Integer` indicating the HTTP protocol major version number. | 
					
						
							| 
									
										
										
										
											2016-11-25 23:17:31 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | #### `response.httpVersionMinor`
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-24 10:29:03 +02:00
										 |  |  | An `Integer` indicating the HTTP protocol minor version number. | 
					
						
							| 
									
										
										
										
											2019-07-22 08:20:43 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | [event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter |