File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,9 @@ self = module.exports = {
214214 if ( body . mode === 'formdata' && options . useMimeType ) {
215215 snippet += indentString + 'curl_mime_free(mime);\n' ;
216216 }
217+ if ( headersData ) {
218+ snippet += indentString + 'curl_slist_free_all(headers);\n' ;
219+ }
217220 snippet += '}\n' ;
218221 snippet += 'curl_easy_cleanup(curl);\n' ;
219222 ( options . includeBoilerplate ) &&
Original file line number Diff line number Diff line change @@ -145,6 +145,38 @@ describe('libcurl convert function', function () {
145145 expect ( snippet ) . to . include ( 'curl_mime_name(part, "invalid src");' ) ;
146146 } ) ;
147147 } ) ;
148+
149+ it ( 'should free up headers list after request is sent' , function ( ) {
150+ var request = new sdk . Request ( {
151+ 'method' : 'GET' ,
152+ 'header' : [
153+ {
154+ 'key' : 'Accept' ,
155+ 'value' : 'application/json'
156+ } ,
157+ {
158+ 'key' : 'Content-Type' ,
159+ 'value' : 'application/json'
160+ }
161+ ] ,
162+ 'url' : {
163+ 'raw' : 'https://google.com' ,
164+ 'protocol' : 'https' ,
165+ 'host' : [
166+ 'google' ,
167+ 'com'
168+ ]
169+ }
170+ } ) ;
171+ convert ( request , { } , function ( error , snippet ) {
172+ if ( error ) {
173+ expect . fail ( null , null , error ) ;
174+ }
175+ expect ( snippet ) . to . be . a ( 'string' ) ;
176+ expect ( snippet ) . to . include ( 'curl_slist_free_all(headers)' ) ;
177+ } ) ;
178+ } ) ;
179+
148180 } ) ;
149181
150182 describe ( 'getOptions function' , function ( ) {
You can’t perform that action at this time.
0 commit comments