//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.IO;
using System.Net;
using DotNetOpenAuth.Messaging;
using Validation;
///
/// A contract for handling.
///
///
/// Implementations of this interface must be thread safe.
///
public interface IDirectWebRequestHandler {
///
/// Determines whether this instance can support the specified options.
///
/// The set of options that might be given in a subsequent web request.
///
/// true if this instance can support the specified options; otherwise, false.
///
[Pure]
bool CanSupport(DirectWebRequestOptions options);
///
/// Prepares an that contains an POST entity for sending the entity.
///
/// The that should contain the entity.
///
/// The stream the caller should write out the entity data to.
///
/// Thrown for any network error.
///
/// The caller should have set the
/// and any other appropriate properties before calling this method.
/// Callers must close and dispose of the request stream when they are done
/// writing to it to avoid taking up the connection too long and causing long waits on
/// subsequent requests.
/// Implementations should catch and wrap it in a
/// to abstract away the transport and provide
/// a single exception type for hosts to catch.
///
Stream GetRequestStream(HttpWebRequest request);
///
/// Prepares an that contains an POST entity for sending the entity.
///
/// The that should contain the entity.
/// The options to apply to this web request.
///
/// The stream the caller should write out the entity data to.
///
/// Thrown for any network error.
///
/// The caller should have set the
/// and any other appropriate properties before calling this method.
/// Callers must close and dispose of the request stream when they are done
/// writing to it to avoid taking up the connection too long and causing long waits on
/// subsequent requests.
/// Implementations should catch and wrap it in a
/// to abstract away the transport and provide
/// a single exception type for hosts to catch.
///
Stream GetRequestStream(HttpWebRequest request, DirectWebRequestOptions options);
///
/// Processes an and converts the
/// to a instance.
///
/// The to handle.
/// An instance of describing the response.
/// Thrown for any network error.
///
/// Implementations should catch and wrap it in a
/// to abstract away the transport and provide
/// a single exception type for hosts to catch. The
/// value, if set, should be Closed before throwing.
///
IncomingWebResponse GetResponse(HttpWebRequest request);
///
/// Processes an and converts the
/// to a instance.
///
/// The to handle.
/// The options to apply to this web request.
/// An instance of describing the response.
/// Thrown for any network error.
///
/// Implementations should catch and wrap it in a
/// to abstract away the transport and provide
/// a single exception type for hosts to catch. The
/// value, if set, should be Closed before throwing.
///
IncomingWebResponse GetResponse(HttpWebRequest request, DirectWebRequestOptions options);
}
}