Comments (19)
There's no procedure in place at the moment. Unless @lxt2 has some other idea, I would think we should tag v1.0.1 and then merge your changes.
from surf.
This should work:
b := surf.NewBrowser()
b.HistoryJar().SetMax(1)
from surf.
The PR was merged into the master branch, but has not been released with a version tag...
Checkout master and you should be seeing the new Methods.
from surf.
Do you actually need the History tracked for that? I'd probably offer a NoopHistory implementation that just dropped history. I don't use the History stuff either.
from surf.
Yes, I guess that would be another way to approach this. In my situation I use Bookmarks but I never go back into History ether. But if you need history, and it grows too big, then you are in a bad place again.
I used the std lib container/list which is a doubly linked list. In my code I set the max to 10 or so and allow it to flow through the list. Not a lot of overhead to manage the pointers in the list and it keeps the History option open.
from surf.
Having a Browser.Close()
method which frees resources sounds like a good idea.
from surf.
If you called Browser.Close()
, would you expect to be able to use it again?
With the current code, simply allowing the Browser object to go out of scope effectively releases all resources to the GC to cleanup.
My issue came in when I was needing to use the Browser over many requests. So I added a method Browser.ClearHistory()
to explicitly clear history at a given point. I also added a Browser.SetMaxHistory(max int)
to limit history growth to a number of items. I left the default at unlimited as to not change the exiting behavior and possibly cause a BC issue, but it might be okay to have a sensible default here of 100 items or something like that.
from surf.
The two methods to clear and limit the history sound good to me too, though I would probably put those methods on the jar.History
interface. (In which case they would be named Clear()
and SetMax()
.)
from surf.
Those two methods do exist on jar.History
, but the current Browser
does not provide access to Browser.history
. So you would have to do something like this:
b := surf.NewBrowser()
hist := jar.NewMemoryHistory()
hist.Max(100)
b.SetHistoryJar(hist)
Because this felt to painful, I added the corresponding methods to the Browser.
b := surf.NewBrowser()
b.SetMaxHistory(100)
Maybe it would just be better to make the History object accessible.
from surf.
Maybe it would just be better to make the History object accessible.
I think that approach would work best, and if we're doing that, we should make the other jar objects accessible as well.
from surf.
Okay. I will work on that.
from surf.
I removed the methods browser.SetMaxHistory()
and browser.ClearHistory()
. I also exposed 4 jar objects so they can be manipulated directly.
from surf.
Looks good, though the Browsable
interface is missing the getter methods. Thanks for your effort in making these changes!
from surf.
Done. We now have the same methods as part of the Browsable
interface.
from surf.
The last item that I would like to do is change the default history length to 100. What is the procedure to make this in a patch release?
from surf.
Is there a PR for this that I've missed?
from surf.
I just added a PR to change the default.
from surf.
I do not understand now... how would you limit history to 1 page now?
from surf.
This should work:
b := surf.NewBrowser() b.HistoryJar().SetMax(1)
There no HistoryJar() method
from surf.
Related Issues (20)
- Check for radio input fails HOT 1
- how can i use bow.CookieJar() map to array?
- javascript libaries / engines implementation HOT 1
- Submiting form do not return every header/cookie
- Is this project support JS? HOT 1
- type browser.Browser not implement browser.Browsable HOT 2
- AddRequestHeader not working HOT 3
- Question: Is is possible to "scroll" in order to get the lazy loaded resources
- Question: Is it possible to support the JavaScript protocol scheme when "clicking" a link?
- forms not found HOT 2
- Get response body not as html
- Await all newtwork calls
- New method: webpage "as user would see" - like htmlunit page.asNormalizedText() HOT 2
- ResolveUrl() don't work with tag <base href="..."> HOT 3
- Status not checked
- Implementing the Socks 5 proxy in the browser HOT 1
- possible to use surf on go rod project?
- Bug in browser.Forms creates nil entries
- Browser does not allow operation with FollowRedirects false
- how to get all fetch/XHR url whit surf?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from surf.