This repository was archived by the owner on Apr 28, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -205,11 +205,11 @@ public function doRequest($request, $response = null)
205
205
}
206
206
207
207
$ headers = $ httpRequest ->getHeaders ();
208
-
208
+
209
209
if (!$ headers ->get ('Content-Type ' )) {
210
210
$ headers ->addHeaderLine ('Content-Type ' , 'text/xml; charset=utf-8 ' );
211
211
}
212
-
212
+
213
213
if (!$ headers ->get ('Accept ' )) {
214
214
$ headers ->addHeaderLine ('Accept ' , 'text/xml ' );
215
215
}
Original file line number Diff line number Diff line change @@ -603,6 +603,36 @@ public function testCustomHttpClientUserAgentIsNotOverridden()
603
603
$ this ->assertSame ($ expectedUserAgent , $ this ->httpClient ->getHeader ('user-agent ' ));
604
604
}
605
605
606
+ public function testContentTypeAutomaticallySet ()
607
+ {
608
+ $ this ->assertFalse (
609
+ $ this ->httpClient ->getHeader ('Content-Type ' ),
610
+ 'Content-Type is null if no request was made '
611
+ );
612
+
613
+ $ expectedContentType = 'text/xml; charset=utf-8 ' ;
614
+ $ this ->httpClient ->setHeaders (['Content-Type ' => $ expectedContentType ]);
615
+
616
+ $ this ->setServerResponseTo (true );
617
+ $ this ->assertTrue ($ this ->xmlrpcClient ->call ('method ' ));
618
+ $ this ->assertSame ($ expectedContentType , $ this ->httpClient ->getHeader ('' ));
619
+ }
620
+
621
+ public function testAcceptAutomaticallySet ()
622
+ {
623
+ $ this ->assertFalse (
624
+ $ this ->httpClient ->getHeader ('Accept ' ),
625
+ 'Accept header is null if no request was made '
626
+ );
627
+
628
+ $ expectedAccept = 'text/xml ' ;
629
+ $ this ->httpClient ->setHeaders (['Accept ' => $ expectedAccept ]);
630
+
631
+ $ this ->setServerResponseTo (true );
632
+ $ this ->assertTrue ($ this ->xmlrpcClient ->call ('method ' ));
633
+ $ this ->assertSame ($ expectedAccept , $ this ->httpClient ->getHeader ('' ));
634
+ }
635
+
606
636
/**
607
637
* @group ZF-8478
608
638
*/
You can’t perform that action at this time.
0 commit comments