// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Web.Http;
namespace System.Net.Http
{
///
/// Provides extension methods for the class.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public static class HttpRequestMessageExtensions
{
///
/// Creates an wired up to the associated .
///
/// The HTTP request.
/// The HTTP status code.
/// An initialized .
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Caller will dispose")]
public static HttpResponseMessage CreateResponse(this HttpRequestMessage request, HttpStatusCode statusCode)
{
if (request == null)
{
throw Error.ArgumentNull("request");
}
return new HttpResponseMessage
{
StatusCode = statusCode,
RequestMessage = request
};
}
///
/// Creates an wired up to the associated .
///
/// The HTTP request.
/// An initialized .
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Caller will dispose")]
public static HttpResponseMessage CreateResponse(this HttpRequestMessage request)
{
if (request == null)
{
throw Error.ArgumentNull("request");
}
return new HttpResponseMessage
{
RequestMessage = request
};
}
}
}