MCPcopy Index your code
hub / github.com/easydiffusion/easydiffusion / post

Method post

ui/media/js/engine.js:457–490  ·  view source on GitHub ↗

Send current task to server. * @param {*} [timeout=-1] Optional timeout value in ms * @returns the response from the render request. * @memberof Task

(url, timeout = -1)

Source from the content-addressed store, hash-verified

455 * @memberof Task
456 */
457 async post(url, timeout = -1) {
458 if (this.status !== TaskStatus.init && this.status !== TaskStatus.pending) {
459 throw new Error(`Task status ${this.status} is not valid for post.`)
460 }
461 this._setStatus(TaskStatus.pending)
462 Object.freeze(this._reqBody)
463
464 const abortSignal = timeout >= 0 ? AbortSignal.timeout(timeout) : undefined
465 let res = undefined
466 try {
467 this.checkReqBody()
468 do {
469 abortSignal?.throwIfAborted()
470 res = await fetch(url, {
471 method: "POST",
472 headers: {
473 "Content-Type": "application/json",
474 },
475 body: JSON.stringify(this._reqBody),
476 signal: abortSignal,
477 })
478 // status_code 503, already a task running.
479 } while (res.status === 503 && (await asyncDelay(RETRY_DELAY_IF_SERVER_IS_BUSY)))
480 } catch (err) {
481 this.abort(err)
482 throw err
483 }
484 if (!res.ok) {
485 const err = new Error(`Unexpected response HTTP${res.status}. Details: ${res.statusText}`)
486 this.abort(err)
487 throw err
488 }
489 return await res.json()
490 }
491
492 static getReader(url) {
493 const reader = new ChunkedStreamReader(url)

Callers 4

postMethod · 0.45
postMethod · 0.45
webui_postFunction · 0.45
jasmineSpec.jsFile · 0.45

Calls 5

_setStatusMethod · 0.95
abortMethod · 0.95
asyncDelayFunction · 0.85
checkReqBodyMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected