Skip to content
Myr

fix(jsx-renderer): don't overwrite headers if stream is `true` (#2363)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* fix(jsx-renderer): dont overwrite headers if stream is `true` * denoify

authored by Yusuke Wada · committed by GitHub · parent 72f8650 · Browse files · 3 files+35 added−18 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+35 added−18 removed

  • tests:+17 added−0 removed
  • other:+18 added−18 removed

3 files+35 added−18 removed

modified:deno_dist/middleware/jsx-renderer/index.ts+9 added-9 removed
modified:src/middleware/jsx-renderer/index.test.tsx+17 added
312 unmodified lines
313</script>`,314 ])315 })316317 it('Should return as streaming content with headers added in a handler', async () => {318 const app = new Hono()319 app.use(jsxRenderer(async ({ children }) => <div>{children}</div>, { stream: true }))320 app.get('/', (c) => {321 c.header('X-Message-Set', 'Hello')322 c.header('X-Message-Append', 'Hello', { append: true })323 return c.render('Hi', { title: 'Hi' })324 })325 const res = await app.request('/')326 expect(res.status).toBe(200)327 expect(res.headers.get('Transfer-Encoding')).toBe('chunked')328 expect(res.headers.get('Content-Type')).toBe('text/html; charset=UTF-8')329 expect(res.headers.get('X-Message-Set')).toBe('Hello')330 expect(res.headers.get('X-Message-Append')).toBe('Hello')331 expect(await res.text()).toBe('<!DOCTYPE html><div>Hi</div>')332 })333334 it('Env', async () => {335 type JSXRendererEnv = {336 Variables: {337 foo: string
98 unmodified lines
modified:src/middleware/jsx-renderer/index.ts+9 added-9 removed