// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
import 'dart:convert';
/// {@template unfreezed_request}
/// A class that represents an unfreezed request.
/// It is used to unfreeze a Request object, and allows you to
/// modify the request before sending it.
/// {@endtemplate}
class UnfreezedRequest {
/// {@macro unfreezed_request}
const UnfreezedRequest({
required this.method,
required this.url,
this.headers,
this.body,
this.encoding,
});
/// The request method.
final String method;
/// The request url.
final Uri url;
/// The request headers.
final Map? headers;
/// The request body.
final Object? body;
/// The request encoding.
final Encoding? encoding;
/// Copies this request and returns a new request with the given [method],
/// [url], [headers], [body] and [encoding].
UnfreezedRequest copyWith({
String? method,
Uri? url,
Map? headers,
Object? body,
Encoding? encoding,
}) =>
UnfreezedRequest(
method: method ?? this.method,
url: url ?? this.url,
headers: headers ?? this.headers,
body: body ?? this.body,
encoding: encoding ?? this.encoding,
);
@override
String toString() => 'UnfreezedRequest(method: $method, url: $url, headers: '
'$headers, body: $body, encoding: $encoding)';
}