@@ -641,20 +641,6 @@ pub const Transfer = struct {
641641 return buf_len ;
642642 }
643643
644- var hdr = & transfer .response_header .? ;
645-
646- if (hdr ._content_type_len == 0 ) {
647- const CONTENT_TYPE_LEN = "content-type:" .len ;
648- if (header .len > CONTENT_TYPE_LEN ) {
649- if (std .ascii .eqlIgnoreCase (header [0.. CONTENT_TYPE_LEN ], "content-type:" )) {
650- const value = std .mem .trimLeft (u8 , header [CONTENT_TYPE_LEN .. ], " " );
651- const len = @min (value .len , hdr ._content_type .len );
652- hdr ._content_type_len = len ;
653- @memcpy (hdr ._content_type [0.. len ], value [0.. len ]);
654- }
655- }
656- }
657-
658644 {
659645 const SET_COOKIE_LEN = "set-cookie:" .len ;
660646 if (header .len > SET_COOKIE_LEN ) {
@@ -668,7 +654,9 @@ pub const Transfer = struct {
668654 }
669655
670656 if (buf_len == 2 ) {
671- if (getResponseHeader (easy , "content-type" )) | value | {
657+ if (getResponseHeader (easy , "content-type" , 0 )) | ct | {
658+ var hdr = & transfer .response_header .? ;
659+ const value = ct .value ;
672660 const len = @min (value .len , hdr ._content_type .len );
673661 hdr ._content_type_len = len ;
674662 @memcpy (hdr ._content_type [0.. len ], value [0.. len ]);
@@ -761,11 +749,19 @@ const HeaderIterator = struct {
761749 }
762750};
763751
764- fn getResponseHeader (easy : * c.CURL , name : [:0 ]const u8 ) ? []const u8 {
752+ const ResponseHeader = struct {
753+ value : []const u8 ,
754+ amount : usize ,
755+ };
756+
757+ fn getResponseHeader (easy : * c.CURL , name : [:0 ]const u8 , index : usize ) ? ResponseHeader {
765758 var hdr : [* c ]c.curl_header = null ;
766- const result = c .curl_easy_header (easy , name , 0 , c .CURLH_HEADER , -1 , & hdr );
759+ const result = c .curl_easy_header (easy , name , index , c .CURLH_HEADER , -1 , & hdr );
767760 if (result == c .CURLE_OK ) {
768- return std .mem .span (hdr .* .value );
761+ return .{
762+ .amount = hdr .* .amount ,
763+ .value = std .mem .span (hdr .* .value ),
764+ };
769765 }
770766
771767 if (result == c .CURLE_FAILED_INIT ) {
0 commit comments