File tree Expand file tree Collapse file tree 1 file changed +15
-14
lines changed
WebApiClientCore/HttpContents Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -111,15 +111,18 @@ public void AddFormField(IEnumerable<KeyValue> keyValues)
111111 /// 添加已编码的原始内容表单
112112 /// </summary>
113113 /// <param name="encodedForm">表单内容</param>
114- public void AddForm ( string ? encodedForm )
114+ public void AddForm ( ReadOnlySpan < char > encodedForm )
115115 {
116- if ( encodedForm == null )
116+ this . EnsureNotBuffered ( ) ;
117+
118+ if ( encodedForm . Length > 0 )
117119 {
118- return ;
120+ if ( this . bufferWriter . WrittenCount > 0 )
121+ {
122+ this . bufferWriter . Write ( ( byte ) '&' ) ;
123+ }
124+ httpEncoding . GetBytes ( encodedForm , this . bufferWriter ) ;
119125 }
120-
121- var formBytes = httpEncoding . GetBytes ( encodedForm ) ;
122- this . AddForm ( formBytes ) ;
123126 }
124127
125128 /// <summary>
@@ -130,16 +133,14 @@ public void AddForm(ReadOnlySpan<byte> encodedForm)
130133 {
131134 this . EnsureNotBuffered ( ) ;
132135
133- if ( encodedForm . IsEmpty == true )
136+ if ( encodedForm . Length > 0 )
134137 {
135- return ;
136- }
137-
138- if ( this . bufferWriter . WrittenCount > 0 )
139- {
140- this . bufferWriter . Write ( ( byte ) '&' ) ;
138+ if ( this . bufferWriter . WrittenCount > 0 )
139+ {
140+ this . bufferWriter . Write ( ( byte ) '&' ) ;
141+ }
142+ this . bufferWriter . Write ( encodedForm ) ;
141143 }
142- this . bufferWriter . Write ( encodedForm ) ;
143144 }
144145
145146 /// <summary>
You can’t perform that action at this time.
0 commit comments