File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,21 @@ exports.XMLHttpRequest = function() {
218218 return result . substr ( 0 , result . length - 2 ) ;
219219 } ;
220220
221+ /**
222+ * Gets a request header
223+ *
224+ * @param string name Name of header to get
225+ * @return string Returns the request header or empty string if not set
226+ */
227+ this . getRequestHeader = function ( name ) {
228+ // @TODO Make this case insensitive
229+ if ( typeof name === "string" && headers [ name ] ) {
230+ return headers [ name ] ;
231+ }
232+
233+ return "" ;
234+ }
235+
221236 /**
222237 * Sends the request to the server.
223238 *
Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ assert.equal(null, xhr.getResponseHeader("Content-Type"));
5050try {
5151 xhr . open ( "GET" , "http://localhost:8000/" ) ;
5252 xhr . setRequestHeader ( "X-Test" , "Foobar" ) ;
53+ // Test getRequestHeader
54+ assert . equal ( "Foobar" , xhr . getRequestHeader ( "X-Test" ) ) ;
5355 xhr . send ( ) ;
5456} catch ( e ) {
5557 console . log ( "ERROR: Exception raised" , e ) ;
You can’t perform that action at this time.
0 commit comments