/*
* Copyright (c) 2022 Vaughn Nugent
*
* Library: VNLib
* Package: VNLib.Net.Messaging.FBM
* File: ClientExtensions.cs
*
* ClientExtensions.cs is part of VNLib.Net.Messaging.FBM which is part of the larger
* VNLib collection of libraries and utilities.
*
* VNLib.Net.Messaging.FBM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* VNLib.Net.Messaging.FBM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
using System;
using System.Runtime.CompilerServices;
namespace VNLib.Net.Messaging.FBM.Client
{
public static class ClientExtensions
{
///
/// Writes the location header of the requested resource
///
///
/// The location address
///
public static void WriteLocation(this FBMRequest request, ReadOnlySpan location)
{
request.WriteHeader(HeaderCommand.Location, location);
}
///
/// Writes the location header of the requested resource
///
///
/// The location address
///
public static void WriteLocation(this FBMRequest request, Uri location)
{
request.WriteHeader(HeaderCommand.Location, location.ToString());
}
///
/// If the property is false, raises an
///
///
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ThrowIfNotSet(this in FBMResponse response)
{
if (!response.IsSet)
{
throw new InvalidResponseException("The response state is undefined (no response received)");
}
}
}
}