Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi RESTDebugger获取请求URL编码的哈希%23不工作_Rest_Delphi_Url Encoding - Fatal编程技术网

Delphi RESTDebugger获取请求URL编码的哈希%23不工作

Delphi RESTDebugger获取请求URL编码的哈希%23不工作,rest,delphi,url-encoding,Rest,Delphi,Url Encoding,我需要简单的休息,让电话正常工作 .../process('123') -> working .../process('123#') -> of course not working .../process('123%23') -> should be working 在REST工具“Postman”中,它正在使用编码的URL,即#->%23 我尝试了以下设置 Content-type: application/json; charset=utf-8 Content-ty

我需要简单的休息,让电话正常工作

.../process('123')  -> working
.../process('123#') -> of course not working
.../process('123%23') -> should be working
在REST工具“Postman”中,它正在使用编码的URL,即#->%23

我尝试了以下设置

Content-type: application/json; charset=utf-8

Content-type: application/x-www-form-urlencoded; charset=UTF-8
两者都不起作用

请指教 谢谢
单元Datasnap.DSClientRest中的Ralph

EncodeURIComponent会给我造成同样的问题

我的修复方法是将单元复制到源目录,并更改函数EncodeURIComponent,将tnetencode.URL.Encode的选项从
[]
更改为
[TURLEncoding.TEncodeOption.EncodePercent]
,因此新的结果行如下所示:

Result := TNetEncoding.URL.Encode(AStr, UnsafeChars, [TURLEncoding.TEncodeOption.EncodePercent]);
原因是,如果在没有
[TURLEncoding.TEncodeOption.EncodePercent]
的情况下调用该部件

if not(TEncodeOption.EncodePercent in Options) and (I + 2 < Len) and (Buff[I] = Ord('%')) and
    IsHexChar(Buff[I + 1]) and IsHexChar(Buff[I + 2]) then
  begin
    Result := Result + '%' + Char(Buff[I + 1]) + Char(Buff[I + 2]);
    Inc(I, 3);
  end
if not(选项中的TEncodeOption.EncodePercent)和(I+2

如果以下两个字符是有效的十六进制字符,则不会对%进行编码

如果从助手生成的Restserver/Client项目中使用ClientModule1.ServerMethods1Client.EchoString(“%123%”),您将看到发生了什么,结果将是3%。我怀疑Datasnap.DSClientRest中的EncodeURIComponent就是罪魁祸首。类似的情况似乎发生了:
Edit1.Text:=“Param=%123%”;Edit2.Text:=EncodeURIComponent(Edit1.Text);Edit3.Text:=tnetencode.URL.Decode(Edit2.Text)
我怀疑通过更改
Result:=tnetencode.URL.Encode(asr,unsechars,[]),问题会得到解决
to
Result:=tnetencode.URL.Encode(asr,unsechars,[TURLEncoding.TEncodeOption.EncodePercent])