如果您
response.write('<imgsrc="my_pic.jpg"/>');如上所述进行操作,则仅当浏览器为图像发送GET时,才会发送图像文件。这将成为多部分请求。或者您可以这样做。可以以HTML二进制格式发送图像。用 :
<img >
其中imagedata是gif图像的base64编码。所以在node.js中这样做:
//Write text in response.content = get-image-file-contents; //store image into contentimagedata = new Buffer(content).toString('base64'); //enpre to base64response.write('<img >');//send imageresponse.end();这发送一个响应,该响应同时发送文本和图像。只需一个标头即可响应
response.writeHead(200, {'content-type':'text/html'});


