dongying195959 2018-07-22 21:35
浏览 274

将“%20”传递给字符串以编码为URL而不转换为空格?

I have the following code to post data to a site: https://play.golang.org/p/e1g0Nd1kDh0

When I view the request in Fiddler, it shows as:

"jobTitle=Area Manager"

What I want it to do is send the string exactly as it is in the code (i.e. not encode the %20 to spaces), as it seems to be causing some confusion on the other side? An identical request made using a Python program works fine where the spaces are not added.

I've tried escaping it by doubling the % signs, but it doesn't seem to work. Any help would be great.

Thanks.

  • 写回答

1条回答 默认 最新

  • duanchensou8685 2018-07-22 22:15
    关注

    If you're trying to receive a literal %20 on the server side, then encode the % sign. It encodes to %25. So your postdata becomes:

        data := "&jobTitle=Area%25%20Manager"
    

    But if this is happening, there is probably a problem on the server side where the postdata is being decoded twice.

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line