LensStudio:Network.HttpReply
ClassHandle to an in-progress HTTP request returned by performHttpRequestWithReply; must be retained to keep the connection alive.
Index
Example
// HttpReply is returned by performHttpRequestWithReply and exposes
// three signals: onData, onEnd, and onError for streaming responses.
const { HttpRequest, performHttpRequestWithReply } = await import('LensStudio:Network');
const request = new HttpRequest();
request.url = 'https://httpbin.org/get';
request.method = HttpRequest.Method.Get;
const reply = performHttpRequestWithReply(request);
// onData fires for each chunk of response data (Editor.Buffer)
this.connections.push(
reply.onData.connect((chunk: Editor.Buffer) => {
console.log('Received data chunk:', chunk.toString().length, 'chars');
})
);
// onEnd fires once with the final HttpResponse when complete
this.connections.push(
reply.onEnd.connect((response: import('LensStudio:Network').HttpResponse) => {
console.log('Request complete, status:', response.statusCode);
console.log('Content-Type:', response.contentType);
})
);
// onError fires if the request fails
this.connections.push(
reply.onError.connect((response: import('LensStudio:Network').HttpResponse) => {
console.log('Request error:', response.error);
})
);
console.log('HttpReply created with onData, onEnd, onError signals connected');
Extends
Properties
onData
Signal fired when a chunk of response data is received, providing an Editor.Buffer with the chunk contents.
onEnd
readonlyonEnd:signal1<HttpResponse,void>
Signal fired when the HTTP response has fully completed, providing the final HttpResponse.
onError
readonlyonError:signal1<HttpResponse,void>
Signal fired when the HTTP request encounters an error, providing the HttpResponse with error details.
Methods
getTypeName()
staticgetTypeName():string
Returns the type name of this class.
Returns
string
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object is of the specified type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object refers to the same instance as the given object.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean