deno_std: console.log(headers) doesn't print useful info
I have problems to read the headers of a ServerRequest
.
I have updated the dependencies with the --reload
flag, but the error still exists.
Is this a Bug or am i doing it wrong?
This is the Code i use:
import { serve } from "https://deno.land/std/http/server.ts";
const test = async () => {
const _s = serve('0.0.0.0:8000')
for await (const req of _s) {
console.log(req.headers)
req.respond({ body: new TextEncoder().encode("Hello World\n") })
}
}
test();
let res = fetch('http://0.0.0.0:8000/test', {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
'test': 'test'
},
body: 'test'
}).then(res => res)
res = fetch('http://0.0.0.0:8000/test').then(res => res)
This is the console output i get:
Headers {}
Headers {}
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (9 by maintainers)
By submitting a PR adding it to the Headers class. I think we need to remove most of the case logic in the
inspect()
to this symbol anyways, as it would be tightly coupled to the class it represents than located specifically in the logic ofinspect()
.In the case of internal Deno code, you would need to
import { customInspect } from "./console";
, but the concept is the same.Here’s a possible implementation:
Should I open a PR in Deno core?
My bad, i was just to stupid:
does the trick