当前位置: 首页>>代码示例>>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;未经允许,请勿转载。