Skip to content

stream: support raw Response content #20

@wenchy

Description

@wenchy

refer: https://requests.readthedocs.io/en/latest/user/quickstart/#raw-response-content

In the rare case that you’d like to get the response Body stream (io.ReadCloser) from the server, you can access r.Raw(). If you want to do this, make sure you set stream as true in your initial request. Once you do, you can do this:

resp, err := requests.Get("http://example.com", requests.Stream(true))

Implementation

add option:

type Options struct {
	// ...
	Stream bool
}

// Stream sets whether need streamed response from the server, you can access resp.Raw(). 
func Stream(yes bool) Option {
	return func(opts *Options) {
		opts.Stream = yes
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions