File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 55use Markenwerk \BasicHttpClient \Request \RequestInterface ;
66use Markenwerk \BasicHttpClient \Response \Header \Header ;
77use Markenwerk \BasicHttpClient \Response \Statistics \Statistics ;
8+ use Markenwerk \BasicHttpClient \Util \HeaderNameUtil ;
89
910/**
1011 * Class AbstractResponse
@@ -107,6 +108,32 @@ public function getHeaders()
107108 return $ this ->headers ;
108109 }
109110
111+ /**
112+ * @param string $name
113+ * @return bool
114+ */
115+ public function hasHeader ($ name )
116+ {
117+ return !is_null ($ this ->getHeader ($ name ));
118+ }
119+
120+ /**
121+ * @param string $name
122+ * @return Header
123+ */
124+ public function getHeader ($ name )
125+ {
126+ $ headers = $ this ->getHeaders ();
127+ $ headerNameUtil = new HeaderNameUtil ();
128+ $ name = $ headerNameUtil ->normalizeHeaderName ($ name );
129+ foreach ($ headers as $ header ) {
130+ if ($ header ->getNormalizedName () == $ name ) {
131+ return $ header ;
132+ }
133+ }
134+ return null ;
135+ }
136+
110137 /**
111138 * @return mixed
112139 */
Original file line number Diff line number Diff line change @@ -48,6 +48,18 @@ public function getStatusText();
4848 */
4949 public function getHeaders ();
5050
51+ /**
52+ * @param string $name
53+ * @return bool
54+ */
55+ public function hasHeader ($ name );
56+
57+ /**
58+ * @param string $name
59+ * @return Header
60+ */
61+ public function getHeader ($ name );
62+
5163 /**
5264 * @return string
5365 */
You can’t perform that action at this time.
0 commit comments