Skip to content

Commit

Permalink
Bugfix/#597 headers panic (#602)
Browse files Browse the repository at this point in the history
* Remodeled HTTPHeaders

* Remodeled HTTPCookies

* Fixed cookie.Expires

* Update documentation
  • Loading branch information
ziflex authored Mar 27, 2021
1 parent d55bce3 commit 3ddd9b8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions pkg/stdlib/html/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,17 @@ type PageLoadParams struct {
// @param {Int} [params.timeout=60000] - Page load timeout.
// @param {String} [params.userAgent] - Custom user agent.
// @param {Boolean} [params.keepCookies=False] - Boolean value indicating whether to use cookies from previous sessions i.e. not to open a page in the Incognito mode.
// @param {HTTPCookies} [params.cookies] - Set of HTTP cookies to use during page loading.
// @param {HTTPHeaders} [params.headers] - Set of HTTP headers to use during page loading.
// @param {Object[] | Object} [params.cookies] - Set of HTTP cookies to use during page loading.
// @param {String} params.cookies.*.name - Cookie name.
// @param {String} params.cookies.*.value - Cookie value.
// @param {String} params.cookies.*.path - Cookie path.
// @param {String} params.cookies.*.domain - Cookie domain.
// @param {Int} [params.cookies.*.maxAge] - Cookie max age.
// @param {String|DateTime} [params.cookies.*.expires] - Cookie expiration date time.
// @param {String} [params.cookies.*.sameSite] - Cookie cross-origin policy.
// @param {Boolean} [params.cookies.*.httpOnly=false] - Cookie cannot be accessed through client side script.
// @param {Boolean} [params.cookies.*.secure=false] - Cookie sent to the server only with an encrypted request over the HTTPS protocol.
// @param {Object} [params.headers] - Set of HTTP headers to use during page loading.
// @param {Object} [params.ignore] - Set of parameters to ignore some page functionality or behavior.
// @param {Object[]} [params.ignore.resources] - Collection of rules to ignore resources during page load and navigation.
// @param {String} [params.ignore.resources.*.url] - Resource url pattern. If set, requests for matching urls will be blocked. Wildcards ('*' -> zero or more, '?' -> exactly one) are allowed. Escape character is backslash. Omitting is equivalent to "*".
Expand Down Expand Up @@ -303,14 +312,14 @@ func parseCookie(value core.Value) (drivers.HTTPCookie, error) {
expires, exists := co.Get("expires")

if exists {
if err = core.ValidateType(maxAge, types.DateTime, types.String); err != nil {
if err = core.ValidateType(expires, types.DateTime, types.String); err != nil {
return drivers.HTTPCookie{}, err
}

if expires.Type() == types.DateTime {
cookie.Expires = expires.(values.DateTime).Unwrap().(time.Time)
} else {
t, err := time.Parse(expires.String(), values.DefaultTimeLayout)
t, err := time.Parse(values.DefaultTimeLayout, expires.String())

if err != nil {
return drivers.HTTPCookie{}, err
Expand Down

0 comments on commit 3ddd9b8

Please sign in to comment.