Skip to content

Response not getting cached when using .Bytes() or .String() methods #73

@HittingSmoke

Description

@HittingSmoke

I read the response quirks on the readme but have so far been unable to get a struct populated using the response.JSON() method.

I'm using the latest version of grequests with Go 1.11. Here is the chunk of code in question:

        resp, _ := session.Post(loginapi, ro)

	fmt.Println(resp.Bytes())
	fmt.Println(resp.String()) // S1
	fmt.Println(resp.StatusCode)

	var r = new(APIResponse)

	fmt.Println(resp.JSON(&r))
	fmt.Println(resp.String()) // S2

In this scenario, S1 will print the response string and S2 will be empty. If I remove the resp.JSON() line everything works fine. Even if I try to call resp.JSON() first to populate before any other response method calls, the struct comes back nil.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions