ds34222222 2017-11-08 12:35
浏览 124

Golang Http客户端请求在自定义Http状态代码上失败

We are rewriting an old integration with a service from python to golang. This service uses Custom status codes. For example the status code is 8000. But while I am trying to get the response it is giving me error as “malformed HTTP status code”. Can some one help me to resolve this issue. Gone through the code and found the following piece of code that throws the error if the status code is not having length of 3.

   if len(statusCode) != 3 {
    return nil, &badStringError{"malformed HTTP status code", statusCode}
}

EDIT: I do understand the RFC standard for HTTP status is 3 digits. But I am re-integrating a legacy code of a Banking system. So I cannot / dont have the access to change the service's implementation.

To give more context, python's http library was not doing this validation. (I am not saying that One language is superior to another, so please dont compare the languages/libraries) So wondering if there is any way to bypass this particular validation. Thanks in advance for understanding..

  • 写回答

2条回答 默认 最新

  • dtkl55257 2017-11-08 12:45
    关注

    From RFC 2616:

    The Status-Code element is a 3-digit integer result code of the attempt

    What you have there is not valid HTTP. If you can get hold of the socket directly, you could try parsing the raw TCP data.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看