1+
2+ #nullable enable
3+
4+ namespace tryAGI . OpenAI
5+ {
6+ /// <summary>
7+ /// Represents a successful HTTP response with status code and headers.
8+ /// </summary>
9+ public partial class AutoSDKHttpResponse
10+ {
11+ /// <summary>
12+ /// Initializes a new instance of the <see cref="AutoSDKHttpResponse"/> class.
13+ /// </summary>
14+ public AutoSDKHttpResponse (
15+ global ::System . Net . HttpStatusCode statusCode ,
16+ global ::System . Collections . Generic . Dictionary < string , global ::System . Collections . Generic . IEnumerable < string > > headers )
17+ {
18+ StatusCode = statusCode ;
19+ Headers = headers ?? throw new global ::System . ArgumentNullException ( nameof ( headers ) ) ;
20+ }
21+
22+ /// <summary>
23+ /// Gets the HTTP status code.
24+ /// </summary>
25+ public global ::System . Net . HttpStatusCode StatusCode { get ; }
26+ /// <summary>
27+ /// Gets the response headers.
28+ /// </summary>
29+ public global ::System . Collections . Generic . Dictionary < string , global ::System . Collections . Generic . IEnumerable < string > > Headers { get ; }
30+
31+ internal static global ::System . Collections . Generic . Dictionary < string , global ::System . Collections . Generic . IEnumerable < string > > CreateHeaders (
32+ global ::System . Net . Http . HttpResponseMessage response )
33+ {
34+ response = response ?? throw new global ::System . ArgumentNullException ( nameof ( response ) ) ;
35+
36+ var headers = global ::System . Linq . Enumerable . ToDictionary (
37+ response . Headers ,
38+ static header => header . Key ,
39+ static header => ( global ::System . Collections . Generic . IEnumerable < string > ) global ::System . Linq . Enumerable . ToArray ( header . Value ) ,
40+ global ::System . StringComparer . OrdinalIgnoreCase ) ;
41+
42+ if ( response . Content ? . Headers == null )
43+ {
44+ return headers ;
45+ }
46+
47+ foreach ( var header in response . Content . Headers )
48+ {
49+ if ( headers . TryGetValue ( header . Key , out var existingValues ) )
50+ {
51+ headers [ header . Key ] = global ::System . Linq . Enumerable . ToArray (
52+ global ::System . Linq . Enumerable . Concat ( existingValues , header . Value ) ) ;
53+ }
54+ else
55+ {
56+ headers [ header . Key ] = global ::System . Linq . Enumerable . ToArray ( header . Value ) ;
57+ }
58+ }
59+
60+ return headers ;
61+ }
62+ }
63+
64+ /// <summary>
65+ /// Represents a successful HTTP response with status code, headers, and body.
66+ /// </summary>
67+ public partial class AutoSDKHttpResponse < T > : AutoSDKHttpResponse
68+ {
69+ /// <summary>
70+ /// Initializes a new instance of the <see cref="AutoSDKHttpResponse{T}"/> class.
71+ /// </summary>
72+ public AutoSDKHttpResponse (
73+ global ::System . Net . HttpStatusCode statusCode ,
74+ global ::System . Collections . Generic . Dictionary < string , global ::System . Collections . Generic . IEnumerable < string > > headers ,
75+ T body )
76+ : base ( statusCode , headers )
77+ {
78+ Body = body ;
79+ }
80+
81+ /// <summary>
82+ /// Gets the response body.
83+ /// </summary>
84+ public T Body { get ; }
85+ }
86+ }
0 commit comments