Expected "Hello World" response body, got "HTTP/1.1 20"
See original GitHub issueIssue
I get this error when I’m asserting a response body. For some reason it asserts with a raw HTTP response:
res.format(obj) > should send text by default
Error: expected "Hello World" response body, got "HTTP/1.1 20"
at error (https://deno.land/x/superdeno@4.4.0/src/test.ts:637:15)
at Test.#assertBody (https://deno.land/x/superdeno@4.4.0/src/test.ts:535:16)
at Test.#assertFunction (https://deno.land/x/superdeno@4.4.0/src/test.ts:617:13)
at Test.#assert (https://deno.land/x/superdeno@4.4.0/src/test.ts:480:35)
at https://deno.land/x/superdeno@4.4.0/src/test.ts:455:23
at async close (https://deno.land/x/superdeno@4.4.0/src/close.ts:48:46)
failures:
res.format(obj) > should send text by default
test result: FAILED. 121 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out (4184ms)
Setup:
deno 1.12.0 (release, x86_64-unknown-linux-gnu) v8 9.2.230.14 typescript 4.3.2
- SuperDeno Version: 4.4.0
Details
import { describe, it, run } from 'https://deno.land/x/tincan@0.2.1/mod.ts'
import { App, Handler, AppConstructor, Request, Response } from 'https://deno.land/x/tinyhttp/mod.ts'
const runServer = (h: Handler) => {
const app = new App()
app.use(h)
const request = superdeno(app.attach)
return request
}
it('should send text by default', async () => {
const request = runServer((req, res) => {
formatResponse(req, res, () => {})({
text: (req: Request) => req.respond({ body: `Hello World` })
}).end()
})
await request.get('/').expect(200).expect('Hello World')
})
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
http2 request to a http1 fastify server hits "default handler for ...
Expected Behavior. http2 requests to an http1 server should not lead to warning log entries. it seems like maybe fastify should respond with...
Read more >HTTP/1.1 200 OK doesn't work? - Stack Overflow
This rule about newline style and US-ASCII encoding only applies to the HTTP header, the response body are free to use other newline...
Read more >Asserting Response - Hurl
Asserting Response. Version - Status. Expected protocol version and status code of the HTTP response. Protocol version is one of HTTP/1.0 , HTTP/1.1...
Read more >Hello World, With Content Types - Pedestal
It's time to see how Pedestal handles content types and response bodies. We will also get our first taste of interceptors.
Read more >HTTP/1.1: Status Code Definitions
The request has succeeded. The information returned with the response is dependent on the method used in the request, for example: GET an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@cmorten ah my bad, the source for
formatResponse
is here:https://github.com/deno-libs/tinyhttp/blob/755c42572a0ba617bb1e97ff374d4d1dc27fd834/extensions/res/format.ts#L11-L41
it’s almost the same as in Opine’s
res.format
regarding
app.attach
… it just immediately mounts the app handler to a server, so nothing fancy.you can check the source here: https://github.com/deno-libs/tinyhttp/blob/755c42572a0ba617bb1e97ff374d4d1dc27fd834/app.ts#L143
tomorrow I’ll try to make a reproduction with
serve
instead and I’ll see what’s happeningIssue lies upstream.