Home > Back-end >  Tidhttp url is too long to 400 bad request
Tidhttp url is too long to 400 bad request

Time:11-16

Everybody is good, I use tidhttp pass data to the mes system, the entire url is more than 9000 letters, the post times 400 bad request, if you remove some data to more than 8000, after upload ok, no grammar mistakes, such as please see is what reason, post any limit to the length, please grant instruction!

CodePudding user response:

With the url and have limited length, use the post data should be placed inside the body, also not directly put the url,

CodePudding user response:

Can take the example upstairs, I have tried like this:
RespData:=TStringStream. Create (");
P:=TStringlist. Create;
P.a dd (rawdata="' + strrawdata);//strrawdata tens of thousands of characters
Idhttp. Post (' http://192.168.10.1:80/mes/integrateservelet? ', p, respdata);

But the server side and didn't receive rawdat data

CodePudding user response:

Server is set to post to receive, if not receive the client side should have an error, you can consult my code, is the Java server, json format data,

 
HTTP. HandleRedirects:=True;
HTTP. ReadTimeout:=20000;
HTTP. Request. ContentType:='application/json;
Http.Com pressor:=TIdCompressorZLib. Create (HTTP);
ResponseStream:=TStringStream. Create (");
RequestStream:=TStringStream. Create (Jo. AsJSon ());
RequestStream. Position:=0;
HTTP Post (AUrl, requestStream responseStream);
Result:=UTF8Decode (responseStream. DataString);

CodePudding user response:

The method of simple:
Var Data: TIdMultiPartFormDataStream;
The begin
Data:=TIdMultiPartFormDataStream. Create;
Try
Data. AddFormField (rawdata, Data_string);
IdHTTP1. Post (URL_string, Data);
The finally
Data. Free;
end;
end;

CodePudding user response:

Could you use the Delphi, I use delphi6 seemingly can't realize your method

CodePudding user response:

Delphi7 + indy10.2
Implementation should be the problem of indy version

CodePudding user response:

Too long in the post

CodePudding user response:

Indy must use indy10 (currently 10.6. XXX), don't use indy9, indy10 architecture changes more, if using the previous version, program transplantation to high version will have trouble

CodePudding user response:

Under a indy10 try tomorrow, with indy10, parameters in the url, will it be a length limit?
Before use delphi6, indy9 parameters in p.a dd (' raw_data=https://bbs.csdn.net/topics/datastring), the server returns ok but didn't receive raw_data.

CodePudding user response:

Problem has been solved, with d7 + indy10.2.3, idhttp. Post (url, request, response), with short length parameters in the url, with a long parameters in the request, not with d6 + indy10.2.3 transfer request, thank you,
  • Related