What is http RoundTripper

agolangf · 2015-05-21 11:47:18 · 4406 次点击    
这是一个分享于 2015-05-21 11:47:18 的资源,其中的信息可能已经有所发展或是发生改变。

Hi all, Can someone explain, what is http roundtripper?

Thanks


评论:

pierrrre:

http://golang.org/pkg/net/http/#RoundTripper It's like a low level http client.

zero_coding:

what can I do with a roundtripper?

jewishobo:

Here is a long video about using the roundtripper interface to make an HTTP/2 client. https://www.youtube.com/watch?v=yG-UaBJXZ80

comrade_donkey:

Take a look at http.Transport

drvd:

It is an interface, so all you can do is invoke its single method RoundTrip and I think the documentation is pretty clear.

kodemizer:

For http clients, it's behaviour can be configured using different RoundTripper implementations. By default, an http client will use an appropriately configured Transport struct (which satisfies a RoundTripper).

By default, the Transport struct is configured to re-use network connections from a pool, timeout after a certain amount of time, use a certain proxy service etc.

If you wanted to modify the behavior of your http client you have two options:

  1. Use the pre-existing Transport struct and configure appropriately.

  2. Write your very own implementation. As long as it satisfies RoupTripper, it can be used. You could do something creative like implement http over SSH, or some other crazy madness.


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

4406 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传