Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
c97e2e74
...
c97e2e74260b2774543c761348324a1c994503dc
authored
2012-07-18 16:55:20 +0200
by
oncletom
Committed by
Nicolas Perriault
2012-10-18 09:43:57 +0200
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Providing `getCurrentHeader` and `getCurrentHeaders`
1 parent
18a7ae83
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
modules/casper.js
modules/casper.js
View file @
c97e2e7
...
...
@@ -733,6 +733,38 @@ Casper.prototype.getCurrentUrl = function getCurrentUrl() {
};
/**
* Retrieves all the currentResponse headers
* Each item follows this structure: `{name: 'Header-Name', value: 'Header-Value'}`.
*
* @return Array
*/
Casper
.
prototype
.
getCurrentHeaders
=
function
getCurrentHeaders
()
{
"use strict"
;
return
this
.
currentResponse
===
undefined
?
[]
:
this
.
currentResponse
.
headers
;
};
/**
* Retrieves a given header based on its name
*
* @param String name A case-sensitive response header name
* @return mixed A header string or `null` if not found
*/
Casper
.
prototype
.
getCurrentHeader
=
function
getCurrentHeader
(
name
)
{
"use strict"
;
var
headerValue
=
null
;
this
.
getCurrentHeaders
().
some
(
function
(
header
){
if
(
header
.
name
===
name
){
headerValue
=
header
.
value
;
}
});
return
headerValue
;
};
/**
* Retrieves the value of an attribute on the first element matching the provided
* DOM CSS3/XPath selector.
*
...
...
Please
register
or
sign in
to post a comment