Closed lengfangbing closed 4 years ago
Your server is too heavy to read.
can you try with this simple example? If it doesn't work, let me know
import { Application, Context } from "https://deno.land/x/oak/mod.ts";
import { multiParser } from 'https://raw.githubusercontent.com/deligenius/multiparser/master/mod.ts'
const app = new Application();
app.use(async (ctx) => {
if (ctx.request.url.pathname === '/upload') {
const form = await multiParser(ctx.request.serverRequest)
if (form) {
console.log(form)
}
}
ctx.response.headers.set("Content-Type", "text/html; charset=utf-8")
ctx.response.body = `
<h3>Deno Oak framework</h3>
<form action="/upload" enctype="multipart/form-data" method="post">
<div>Text field title: <input type="text" name="title" /></div>
<div>File: <input type="file" name="singleFile"/></div>
<input type="submit" value="Upload" />
</form>
`
});
await app.listen({ port: 8000 });
Your server is too heavy to read.
can you try with this simple example? If it doesn't work, let me know
import { Application, Context } from "https://deno.land/x/oak/mod.ts"; import { multiParser } from 'https://raw.githubusercontent.com/deligenius/multiparser/master/mod.ts' const app = new Application(); app.use(async (ctx) => { if (ctx.request.url.pathname === '/upload') { const form = await multiParser(ctx.request.serverRequest) if (form) { console.log(form) } } ctx.response.headers.set("Content-Type", "text/html; charset=utf-8") ctx.response.body = ` <h3>Deno Oak framework</h3> <form action="/upload" enctype="multipart/form-data" method="post"> <div>Text field title: <input type="text" name="title" /></div> <div>File: <input type="file" name="singleFile"/></div> <input type="submit" value="Upload" /> </form> ` }); await app.listen({ port: 8000 });
yes, this work now. So It may caused by What I write is too heavy
Your server is too heavy to read.
can you try with this simple example? If it doesn't work, let me know
import { Application, Context } from "https://deno.land/x/oak/mod.ts"; import { multiParser } from 'https://raw.githubusercontent.com/deligenius/multiparser/master/mod.ts' const app = new Application(); app.use(async (ctx) => { if (ctx.request.url.pathname === '/upload') { const form = await multiParser(ctx.request.serverRequest) if (form) { console.log(form) } } ctx.response.headers.set("Content-Type", "text/html; charset=utf-8") ctx.response.body = ` <h3>Deno Oak framework</h3> <form action="/upload" enctype="multipart/form-data" method="post"> <div>Text field title: <input type="text" name="title" /></div> <div>File: <input type="file" name="singleFile"/></div> <input type="submit" value="Upload" /> </form> ` }); await app.listen({ port: 8000 });
Oh yeah, I found the reason. Thats because I read ctx.request.serverRequest.body before MultipartReader. So now I deal with it., And solve it~ Thank you very much~~~
I use this parser. But it has no response. I used postman to send multipart/form-data request, but it was sending forever and never stop. I think it had no condition to stop read? or other reason? The output terminal had no error message. If I cancel the request, It showed error. I think thats the same question here https://github.com/denoland/deno/issues/5830
deno-demo2.zip