dongqiang5541 2018-02-25 18:17
浏览 140

header.Write / WriteSubset的惯用用法是什么?

Go's http.Header has these two methods:

I see that the standard library uses these methods for example when writing request headers, but why are they public/what is a standard use case?

  • 写回答

1条回答 默认 最新

  • dqeq885710 2018-02-25 20:49
    关注

    In general, you would want to export anything that some other package needs to call. Sometimes this can get fairly low-level.

    Header.WriteSubset() would be useful in writing an HTTP proxy. The HTTP specifications say that certain headers are hop-by-hop headers, so that proxies that receive them must not pass them on to the next hop. By contrast, end-to-end headers are always passed on.

    There are probably other uses. httputil.DumpRequest() uses WriteSubset() to exclude some irrelevant headers from its output.

    Exporting Header.Write() is less obvious. Though the Go standard library uses it to implement its CGI and FastCGI servers.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!