Release Notes
1.0.0
Initial release of Albatross.Http, a companion library for HttpClient providing extensions and shared types for HTTP client code generation.
DefaultJsonSerializerOptions
- Static class providing a shared
JsonSerializerOptionsinstance with camelCase naming policy, no indentation, andJsonIgnoreCondition.WhenWritingNull - Used as the default by
RequestBuilder
RequestBuilder
- Fluent builder for constructing
HttpRequestMessagewith support for:- JSON, plain text, stream, and form URL-encoded content
- Multipart form data with files (byte array and stream), string fields, and JSON fields
- Query string parameters (accepts nullable strings)
- Custom
JsonSerializerOptions
- Automatically resets after
Build()for reuse
RequestBuilderExtensions
AddQueryString<T>- generic method for any non-null valueAddQueryStringIfSet<T>(class constraint) - only adds query string if value is not null or emptyAddQueryStringIfSet<T>(struct constraint) - only adds query string if nullable value has a value, with automatic ISO8601 formatting forDateTime,DateOnly,TimeOnly, andDateTimeOffset
HttpClientExtensions
Execute<TResponse>andExecute<TResponse, TError>- send a request and deserialize the response, returning nullable resultSend<TError>- fire-and-forget method for requests that don't return a body but still need error handlingExecuteOrThrow<TResponse>andExecuteOrThrow<TResponse, TError>- guaranteed non-null response for reference types, throwsServiceExceptionon empty or null contentExecuteOrThrowStruct<TResponse>andExecuteOrThrowStruct<TResponse, TError>- guaranteed response for value types, internally deserializes asNullable<T>to detect null JSON valuesExecuteAsStream<TItem>andExecuteAsStream<TItem, TError>- streams the response asIAsyncEnumerable<TItem?>for endpoints usingyield returnorIAsyncEnumerable<T>, usingHttpCompletionOption.ResponseHeadersReadfor true streaming
UrlExtensions
CreateUrl- builds URLs with query string parameters fromNameValueCollectionCreateUrlArray- batches large array query parameters across multiple URLs using repeated keysCreateUrlArrayByDelimitedValue- batches array parameters using a delimiter within a single keyGetFullUri- resolves relative URIs against a base address- ISO8601 format constants and extension methods for
DateOnly,TimeOnly,DateTime, andDateTimeOffset
ServiceException
ServiceException<T>- typed exception carrying HTTP status code, method, endpoint, and a deserialized error objectServiceException- convenience subclass defaulting the error type tostring
LoggingHandler
DelegatingHandlerfor structured logging of HTTP requests and responses viaILogger- Logs request start, completion status, error response bodies, and cancellations
ContentTypes
- MIME type constants for JSON, text, HTML, CSV, form, Excel, octet-stream, multipart form data, and images