unsafe internal static Byte[] marshall(HttpResp response, Object val, MediaType produces) { if (response.StatusCode == 0) { //which indicates that the user did not set this response.StatusCode = 200; } //return values can be Object, any built in Type, a file or nothing. //Process depending on return format specified by the user response.StatusDesc = StatusCodeDesc.GetStatusDesc(response.StatusCode); response.ContentType = response.ContentType.Equals("") == true ? produces : response.ContentType; //package the body correctly Byte[] BodyContent = GetByte(val, produces); response.ContentLength = (UInt64)BodyContent.Length; HttpBody Body = response.Body; Body.SetLengthOfBody(BodyContent.Length); Body.SetBodyContent(BodyContent); return(response.Bytes()); }
internal static byte[] DummyHookFunction(HttpRequest req) { if (null == defByte) { defByte = System.Text.Encoding.UTF8.GetBytes(def); } HttpResponse response = new HttpResponse(); response.StatusDesc = StatusCodeDesc.GetStatusDesc(200); response.ContentType = MediaType.TEXT_PLAIN; response.ContentLength = (UInt64)defByte.Length; HttpBody body = response.Body; body.SetLengthOfBody(defByte.Length); body.SetBodyContent(defByte); return(response.Bytes()); }