Git Product home page Git Product logo

Comments (5)

mna avatar mna commented on June 24, 2024

Hey Jordan,

NewDocument is just a helper func that uses the net/http default client (via http.Get), so whatever timeout you set on the default client (via its underlying transport) will be used. If you don't want to change the default client so that it doesn't interfere with other uses, then you can create your own http client, and pass the response to NewDocumentFromResponse instead.

from goquery.

jwarzech avatar jwarzech commented on June 24, 2024

Thanks! Looks like there isn't a very straightforward way at adding timeouts to Go's default client, does goquery support go-httpclient? Looks like this is a thin wrapper around the default but with timeout supported.

from goquery.

mna avatar mna commented on June 24, 2024

Yeah, setting timeouts is not super straightforward, you can see some options here: http://stackoverflow.com/questions/16895294/how-to-set-timeout-for-http-get-requests-in-golang

Goquery does not support other http clients, but there is a constructor based on an *http.Response (if this client returns stdlib's responses), or based on an io.Reader, so you should be able to get a goquery.Document one way or another.

from goquery.

jwarzech avatar jwarzech commented on June 24, 2024

Thanks Martin! That helped a lot and I have this up and working in production. Since go-httpclient returns the native http.Response I was able to use its timeout functionality and pass the response into goquery. Thanks for making such a flexible library!

from goquery.

mna avatar mna commented on June 24, 2024

Awesome, thanks for the kind words! Best of luck with your project!

from goquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.