當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript wai.createHttpContext函數代碼示例

本文整理匯總了TypeScript中@jonggrang/wai.createHttpContext函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createHttpContext函數的具體用法?TypeScript createHttpContext怎麽用?TypeScript createHttpContext使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了createHttpContext函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

 it('return disl storage if content-length greater than 50000', () => {
   const req = {
     headers: {
       'content-length': 80000
     }
   };
   const storage = defaultGetStorage(createHttpContext(req as any));
   assert.ok(storage instanceof DiskStorage);
 });
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:9,代碼來源:default-storage.ts

示例2: it

 it('should process x-www-form-urlencoded', async function () {
   const req = new PassThrough();
   req.end('name=foo&key=value&abc=xyz');
   (req as any).headers = {
     'content-type': 'application/x-www-form-urlencoded',
     'content-length': 26
   };
   (req as any).method = 'GET';
   (req as any).url = '/upload';
   const ctx = W.createHttpContext(req as any);
   await T.toPromise(middleware(simpleApp)(ctx, T.pure));
   assert.deepEqual(ctx.state.body, {
     name: 'foo',
     key: 'value',
     abc: 'xyz'
   });
 });
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:17,代碼來源:form-fields.ts

示例3: mutter

    (form as any).getLength((err: Error | null, len: number) => {
      if (err) return cb(err);

      const app = mutter(simpleApp);
      const request = new PassThrough();
      (request as any).complete = false;
      form.once('end', () => {
        (request as any).complete = true;
      });

      form.pipe(request);
      (request as any).headers = {
        'content-type': 'multipart/form-data; boundary=' + (form as any).getBoundary(),
        'content-length': len
      };

      const ctx: W.HttpContext = W.createHttpContext(request as any);

      T.runTask(app(ctx, T.pure), err => {
        if (err) return cb(err);

        cb(null, ctx);
      });
    });
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:24,代碼來源:utils.ts

示例4: request

function request(app: Application, req: IncomingMessageMock): T.Task<Response> {
  return app(createHttpContext(req as any), T.pure);
}
開發者ID:syaiful6,項目名稱:jonggrang,代碼行數:3,代碼來源:static.test.ts


注:本文中的@jonggrang/wai.createHttpContext函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。