File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -138,9 +138,14 @@ void AddPostParameters() {
138
138
}
139
139
140
140
void AddHeaders ( ) {
141
- _request . Parameters
141
+ var contentHeaders = _request . Parameters
142
142
. Where ( x => x . Type == ParameterType . HttpHeader && ContentHeaders . Contains ( x . Name ) )
143
- . ForEach ( AddHeader ) ;
143
+ . ToArray ( ) ;
144
+
145
+ if ( contentHeaders . Length > 0 && Content == null )
146
+ throw new InvalidRequestException ( "Content headers should not be used when there's no body in the request" ) ;
147
+
148
+ contentHeaders . ForEach ( AddHeader ) ;
144
149
145
150
void AddHeader ( Parameter parameter ) {
146
151
var parameterStringValue = parameter . Value ! . ToString ( ) ;
@@ -156,10 +161,7 @@ void AddHeader(Parameter parameter) {
156
161
}
157
162
158
163
string GetContentTypeHeader ( string contentType ) {
159
- if ( Content == null )
160
- throw new InvalidRequestException ( "Content type headers should not be used when there's no body in the request" ) ;
161
-
162
- var boundary = Content . GetFormBoundary ( ) ;
164
+ var boundary = Content ! . GetFormBoundary ( ) ;
163
165
return boundary . IsEmpty ( ) ? contentType : $ "{ contentType } ; boundary=\" { boundary } \" ";
164
166
}
165
167
You can’t perform that action at this time.
0 commit comments