Coder Social home page Coder Social logo

HTTP method is overridden about gentleman HOT 6 CLOSED

h2non avatar h2non commented on August 18, 2024
HTTP method is overridden

from gentleman.

Comments (6)

h2non avatar h2non commented on August 18, 2024

Well, that scenario could happen when you define a client level HTTP method.

I've fixed the issue. Try updating gentleman.

go get -u gopkg.in/h2non/gentleman.v0

from gentleman.

solher avatar solher commented on August 18, 2024

Hum. It doesn't seems to solve the problem for me.

I don't define a client level HTTP method. I only do:

type Repository struct {
    c *gentleman.Client
}

func NewRepository() *Repository {
    return &Repository{c: gentleman.New()}
}

And then call the Send method.

from gentleman.

h2non avatar h2non commented on August 18, 2024

Have you tried it again updating gentleman?. It should work now since the method is define either in client or request level via middleware call chain.

from gentleman.

solher avatar solher commented on August 18, 2024

Yeah the update is done.

// Method defines the HTTP verb to be used.
func (r *Request) Method(method string) *Request {
    r.Middleware.UseRequest(func(ctx *context.Context, h context.Handler) {
        ctx.Request.Method = method
        fmt.Print(ctx.Request.Method)
        h.Next(ctx)
    })
    return r
}

Prints GET while the same in the doDial method still prints POST.

from gentleman.

h2non avatar h2non commented on August 18, 2024

I see where is the issue. You're always calling JSON(), which implicitely defines the POST method if no method was previously defined. In that case you should consider calling that method only if payload data exists.

from gentleman.

solher avatar solher commented on August 18, 2024

Oh ok ! Perfect, thanks a lot.

from gentleman.

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.