mirror of
https://github.com/MontFerret/ferret.git
synced 2024-12-14 11:23:02 +02:00
add GetResponse into HTMLPage interface
This commit is contained in:
parent
73c9a01af5
commit
43fb43eb8b
@ -3,6 +3,8 @@ package common
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/MontFerret/ferret/pkg/drivers"
|
||||
"github.com/MontFerret/ferret/pkg/runtime/core"
|
||||
"github.com/MontFerret/ferret/pkg/runtime/values"
|
||||
@ -20,6 +22,14 @@ func GetInPage(ctx context.Context, page drivers.HTMLPage, path []core.Value) (c
|
||||
segment := segment.(values.String)
|
||||
|
||||
switch segment {
|
||||
case "response":
|
||||
resp, err := page.GetResponse(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get response")
|
||||
}
|
||||
|
||||
return resp.GetIn(ctx, path[1:])
|
||||
|
||||
case "mainFrame", "document":
|
||||
return GetInDocument(ctx, page.GetMainFrame(), path[1:])
|
||||
case "frames":
|
||||
|
@ -201,6 +201,8 @@ type (
|
||||
NavigateBack(ctx context.Context, skip values.Int) (values.Boolean, error)
|
||||
|
||||
NavigateForward(ctx context.Context, skip values.Int) (values.Boolean, error)
|
||||
|
||||
GetResponse(ctx context.Context) (*HTTPResponse, error)
|
||||
}
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user