wf0156 2022-08-19 09:00
浏览 10
已结题

delphi.idhttpserver.10.json

有一个问题请教大家,我用indy10.5.8:idhttpserver想接收applicationjson的数据,是从android 发送的数据,但是数据非常大,idhttpserver 收不到是什么原因?delphi7的原版INDY是可以收到数据的,不过收不全.,所以升级了INDY10,但是问题好像更严重了,一点也收不到了.
是有什么地方设置不对么?还是什么原因?
use indy10 idhttpserver recv android sendto PC applicationjson data but jpg in json ,large data ,i have not recv the data .every string is empty,please help
if config wrong ?

code:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,IdContext, StdCtrls, IdBaseComponent, IdComponent, IdCustomTCPServer,
IdCustomHTTPServer, IdHTTPServer;

type
TForm1 = class(TForm)
IdHTTPServer1: TIdHTTPServer;
Memo1: TMemo;
procedure IdHTTPServer1CommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.IdHTTPServer1CommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
post_data:string;
begin
AContext.Connection.IOHandler.MaxLineLength:=-1;

Memo1.Lines.Add('ARequestInfo.Document:='+ARequestInfo.Document);
Memo1.Lines.Add('ARequestInfo.RawHTTPCommand:='+ARequestInfo.RawHTTPCommand);
Memo1.Lines.Add('ARequestInfo.Version:='+ARequestInfo.Version);
Memo1.Lines.Add('ARequestInfo.QueryParams:='+ARequestInfo.QueryParams);
Memo1.Lines.Add('ARequestInfo.Command:='+ARequestInfo.Command);
Memo1.Lines.Add('ARequestInfo.UnparsedParams:='+ARequestInfo.UnparsedParams);
Memo1.Lines.Add('ARequestInfo.FormParams:='+ARequestInfo.FormParams);

if Arequestinfo.command = 'post' then
try

post_data := Arequestinfo.params.gettext;
try
if(post_data<>'')then
begin

savefile(post_data,inttostr(v_suc_num+1)+.txt);

if memo1.lines.count>300 then
memo1.lines.clear;
memo1.lines.add(post_data);

end;

except on e: exception do
begin

Aresponseinfo.responseno := 500;
Aresponseinfo.contenttext := post_data;
Aresponseinfo.contentlength := length(post_data);

exit;
end;
end;
finally

end;
end;
end.
thanks for all friend
2022.8.19

  • 写回答

1条回答 默认 最新

  • wf0156 2022-08-19 10:31
    关注

    你这个问题,百度下就有答案了 "application/x-www-form-urlencoded通过表单提交,在sevlet实现中,mutipart/form-data和application/x-www-form-urlencoded会被特殊处理,请求参数将被放置于request.paramter,这是一个map。 当我们使用content-type=application/json且后台使用@RequestBody,则无法再从request.paramter中获取请求数据。"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 8月27日
  • 已采纳回答 8月19日
  • 创建了问题 8月19日

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用