* fix: ensure the typescript definitions only export correct value types In typescript there are two main types of "types" you can export, value types (class, const) and definition types (type, interface). The typescript compiler will let anything declared via const or class be used as a value. Unfortunately we were exporting a bunch of things (see the diff) as class/const when they weren't actually exported values. This lead to typescript being happy but the runtime throwing errors (not something we want). This change passes "exported-in" context through our docs, to the parser and then to the definitions generator to ensure we only mark things as exported in the ts defs that we actually export. Fixes #22167 * chore: update typescript-defs * chore: update typescript-defs * chore: fix bad typescript in IPC test * docs: test rendering of new syntax * chore: update per feedback, use same syntax but with 'this is not exportedd' line
2.7 KiB
Class: IncomingMessage
Handle responses to HTTP/HTTPS requests.
Process: Main
This class is not exported from the 'electron'
module. It is only available as a return value of other methods in the Electron API.
IncomingMessage
implements the Readable Stream
interface and is therefore an EventEmitter.
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. Must be placed before 'data' event.
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
An Integer
indicating the HTTP response status code.
response.statusMessage
A String
representing the HTTP status message.
response.headers
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
, oruser-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 ', '.
response.httpVersion
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.
response.httpVersionMajor
An Integer
indicating the HTTP protocol major version number.
response.httpVersionMinor
An Integer
indicating the HTTP protocol minor version number.