@@ -682,7 +682,7 @@ pub const Response = struct {
682
682
///
683
683
/// See also:
684
684
/// * `readerDecompressing`
685
- pub fn reader (response : * Response , buffer : []u8 ) * Reader {
685
+ pub fn reader (response : * const Response , buffer : []u8 ) * Reader {
686
686
const req = response .request ;
687
687
if (! req .method .responseHasBody ()) return .ending ;
688
688
const head = & response .head ;
@@ -805,6 +805,11 @@ pub const Request = struct {
805
805
unhandled = std .math .maxInt (u16 ),
806
806
_ ,
807
807
808
+ pub fn init (n : u16 ) RedirectBehavior {
809
+ assert (n != std .math .maxInt (u16 ));
810
+ return @enumFromInt (n );
811
+ }
812
+
808
813
pub fn subtractOne (rb : * RedirectBehavior ) void {
809
814
switch (rb .* ) {
810
815
.not_allowed = > unreachable ,
@@ -855,6 +860,14 @@ pub const Request = struct {
855
860
return result ;
856
861
}
857
862
863
+ /// Transfers the HTTP head and body over the connection and flushes.
864
+ pub fn sendBodyComplete (r : * Request , body : []u8 ) Writer.Error ! void {
865
+ r .transfer_encoding = .{ .content_length = body .len };
866
+ var bw = try sendBodyUnflushed (r , body );
867
+ bw .writer .end = body .len ;
868
+ try bw .end ();
869
+ }
870
+
858
871
/// Transfers the HTTP head over the connection, which is not flushed until
859
872
/// `BodyWriter.flush` or `BodyWriter.end` is called.
860
873
///
@@ -1296,7 +1309,7 @@ pub const basic_authorization = struct {
1296
1309
pub fn value (uri : Uri , out : []u8 ) []u8 {
1297
1310
var bw : Writer = .fixed (out );
1298
1311
write (uri , & bw ) catch unreachable ;
1299
- return bw .getWritten ();
1312
+ return bw .buffered ();
1300
1313
}
1301
1314
1302
1315
pub fn write (uri : Uri , out : * Writer ) Writer.Error ! void {
0 commit comments