Esempio n. 1
0
		static void create_image_response(proxy_transaction thept, string type) {
			Bitmap b = new Bitmap(250,30);
			Image i = Draw.DrawString(
				b,
				String.Format ("Requests to {0} are forbidden!", thept.Request.Host),
				new Point(10,10));
			thept.Response = http_response.CreateBasic(thept.Request,200);
			switch(type) {
			case "gif":
				thept.Response.Header.ContentType = "image/gif";
				thept.Response.Body = meticulus.drawing.Convert.ToGifMemoryStream(i);
				break;
			case "jpg":
				thept.Response.Header.ContentType = "image/jpeg";
				thept.Response.Body = meticulus.drawing.Convert.ToJpegMemoryStream(i);
				break;
			case "png":
				thept.Response.Header.ContentType = "image/png";
				thept.Response.Body = meticulus.drawing.Convert.ToPNGMemoryStream(i);
				break;
			default:
				thept.Response.Header.ContentType = "image/jpeg";
				thept.Response.Body = meticulus.drawing.Convert.ToJpegMemoryStream(i);
				break;
			}
			thept.Response.Header.SetValue ("Content-Length", thept.Response.Body.Length.ToString ());
		}
Esempio n. 2
0
		static void create_html_response (proxy_transaction thept)
		{
			thept.Response = http_response.CreateBasic(thept.Request,403);
			thept.Response.Header.ContentType = "text/html";
			thept.Response.Body = new MemoryStream (Encoding.Default.GetBytes (http_function.CreateBasicHTML (String.Format ("Requests to {0} are forbidden!", thept.Request.Host))));
			thept.Response.Header.SetValue ("Content-Length", thept.Response.Body.Length.ToString ());
		}
Esempio n. 3
0
		static void create_response(proxy_transaction thept) {
			switch(thept.Request.Header.Accepts[0]) {
			case "image/gif":
				create_image_response(thept, "gif");
				break;
			case "image/jpeg":
				create_image_response(thept, "jpg");
				break;
			case "image/png":
				create_image_response(thept, "png");
				break;
			default:
				create_html_response(thept);
				break;
			}
		}