Skip to content

Commit

Permalink
Splitting Ask Class into Request/Response Classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Universal Web committed Sep 15, 2023
1 parent f5cda4c commit 4dc0557
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
51 changes: 51 additions & 0 deletions udsp/request/request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {
promise, assign, omit, eachArray, stringify, get, isBuffer, isPlainObject, isArray, isMap, construct, each, hasLength, hasValue, UniqID
} from '@universalweb/acid';
import { decode, encode } from 'msgpackr';
import {
failed, info, msgReceived, msgSent
} from '#logs';
import { Base } from './base.js';
import { request } from '#udsp/requestMethods/request';
export class Ask extends Base {
constructor(method = 'get', path, parameters, data, head, options = {}, source) {
super(options, source);
const {
requestQueue,
streamIdGenerator,
} = source;
console.log('Ask', data);
const methodSanitized = method.toLowerCase();
this.request.method = methodSanitized;
this.method = methodSanitized;
if (path) {
this.request.path = path;
this.path = path;
}
if (parameters) {
this.request.parameters = parameters;
this.parameters = parameters;
}
if (data) {
this.request.data = data;
}
if (head) {
this.request.head = head;
}
}
completeReceived() {
console.log('Ask complete', this);
if (this.state === 3) {
this.state = 4;
}
this.readyState = 4;
this.flush();
this.accept(this);
}
isRequest = true;
type = 'request';
request = {};
}
export async function ask(source) {
return construct(Ask, omit);
}
6 changes: 6 additions & 0 deletions udsp/request/response.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class UWResponse {
constructor(headers, data) {
}
isResponse = true;
type = 'response';
}

0 comments on commit 4dc0557

Please sign in to comment.