koajs / examples

Example Koa apps
4.52k stars 744 forks source link

Some question about "404" example #107

Closed qeesung closed 7 years ago

qeesung commented 7 years ago

I tried the 404 example , but I found some problems

I tried to make some requests with different custom headers(text/plain and application/json), but the I found that the responses were not what I expected:

➜  ~ http --print=Hhb localhost:3000 Content-Type:text/html
GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Type: text/html
Host: localhost:3000
User-Agent: HTTPie/0.9.9

HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Length: 21
Content-Type: text/html; charset=utf-8
Date: Wed, 03 May 2017 16:48:50 GMT

<p>Page Not Found</p>

➜  ~ http --print=Hhb localhost:3000 Content-Type:application/json
GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Type: application/json
Host: localhost:3000
User-Agent: HTTPie/0.9.9

HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Length: 21
Content-Type: text/html; charset=utf-8
Date: Wed, 03 May 2017 16:50:05 GMT

<p>Page Not Found</p>

➜  ~ http --print=Hhb localhost:3000 Content-Type:multipart/form-data
GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Type: multipart/form-data
Host: localhost:3000
User-Agent: HTTPie/0.9.9

HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Length: 21
Content-Type: text/html; charset=utf-8
Date: Wed, 03 May 2017 16:50:35 GMT

<p>Page Not Found</p>

No matter how I set up what kind of Content-Type,The results are always same.

Is this a bug or my use is not correct?

qeesung commented 7 years ago

Oh , I used a wrong http header

http --print=Hhb localhost:3000 Accept:application/json

is work now.