In C# i am doing
context.Response.ContentType = "image/png";
context.RewritePath(sz);
context.Response.ContentType = "image/png";
It seems to redirect the path as i can see see images on my pages. However in firefox when i right click and select "view image" i get a download. Using this c++ code i can see the mime being application/octet-stream
#include <curl/curl.h>
#include <ios>
#include <iostream>
#include <string>
#pragma comment(lib, "curllib")
using namespace std;
size_t function( void *ptr, size_t size, size_t nmemb, void *stream)
{
cout << (char*)ptr;
return size*nmemb;
}
size_t function2( void *ptr, size_t size, size_t nmemb, void *stream)
{
return size*nmemb;
}
int main()
{
CURL *c = curl_easy_init();
curl_easy_setopt(c, CURLOPT_HEADERFUNCTION, function);
curl_easy_setopt(c, CURLOPT_WRITEHEADER , 1);
curl_easy_setopt(c, CURLOPT_WRITEFUNCTION, function2);
curl_easy_setopt(c, CURLOPT_WRITEDATA, 0);
curl_easy_setopt(c, CURLOPT_URL, "http://localhost:3288/s/main/4/AAA.png");
curl_easy_perform(c);
curl_easy_cleanup(c);
return 0;
}
My question is how do i set the mime to the correct type? Above i hardcode it to png which doesnt work. However i rather not hardcode any mime and have it work. I was able to redirect an XML file to somefile.aspx and have that the page set the content type and generate the XML. However rewriting to the image path seems to let the image work i just dont get the correct type.
How do i correct the content/mime type? As plan B i'll rewrite to a aspx file. Whats the best way to send an image? Could i do something like context.Response.OutputStream=stream("filename"); ?