public static HttpResponse EmptyResponseWithStatusCode(int statusCode) { DefaultHttpResponseFactory responseFactory = new DefaultHttpResponseFactory(); BasicStatusLine statusLine = new BasicStatusLine(HttpVersion.Http11, statusCode, string.Empty); HttpResponse response = responseFactory.NewHttpResponse(statusLine, null); return(response); }
/// <exception cref="System.IO.IOException"></exception> public static HttpResponse GenerateHttpResponseObject(HttpEntity responseEntity) { DefaultHttpResponseFactory responseFactory = new DefaultHttpResponseFactory(); BasicStatusLine statusLine = new BasicStatusLine(HttpVersion.Http11, 200, "OK"); HttpResponse response = responseFactory.NewHttpResponse(statusLine, null); response.SetEntity(responseEntity); return(response); }
/// <exception cref="System.IO.IOException"></exception> public static HttpResponse GenerateHttpResponseObject(object o) { DefaultHttpResponseFactory responseFactory = new DefaultHttpResponseFactory(); BasicStatusLine statusLine = new BasicStatusLine(HttpVersion.Http11, 200, "OK"); HttpResponse response = responseFactory.NewHttpResponse(statusLine, null); byte[] responseBytes = Manager.GetObjectMapper().WriteValueAsBytes(o); response.SetEntity(new ByteArrayEntity(responseBytes)); return(response); }
/// <exception cref="System.IO.IOException"></exception> public static HttpResponse GenerateHttpResponseObject(string responseJson) { DefaultHttpResponseFactory responseFactory = new DefaultHttpResponseFactory(); BasicStatusLine statusLine = new BasicStatusLine(HttpVersion.Http11, 200, "OK"); HttpResponse response = responseFactory.NewHttpResponse(statusLine, null); byte[] responseBytes = Sharpen.Runtime.GetBytesForString(responseJson); response.SetEntity(new ByteArrayEntity(responseBytes)); return(response); }