• delphi xe10 indy 表单post 方法, utf8编码



    // 亲测 不会乱码
    var CuId,ModelId,sid : Integer; lmsg : string; Idc: TIdHTTP; Ptxt : string; postJson,jo :ISuperObject; rst : Boolean; lmfd: TIdMultiPartFormDataStream; responseStream: TStringStream; begin Result := False; try lmfd := TIdMultiPartFormDataStream.Create; responseStream := TStringStream.Create(); lmfd.AddFormField('cuid',vcuid,'UTF-8').ContentTransfer := '8bit' ; lmfd.AddFormField('type',vtype,'UTF-8').ContentTransfer := '8bit'; Idc := TIdHTTP.Create(nil); Idc.ReadTimeout := 60000; Idc.ConnectTimeout := 60000; // Idc.Request.ContentType := 'application/json'; Idc.Request.ContentType := 'application/x-www-form-urlencoded'; Ptxt := ''; try try idc.Post(gqrurl,lmfd,responseStream); ptxt := responseStream.DataString; if ptxt <> '' then begin jo := so(ptxt); rst := jo.B['status']; if rst then begin Result := True; vmsg := jo.S['data']; end; end; except on e: exception do begin vmsg := e.Message; end; end; finally Idc.Free; end; FreeAndNil(responseStream); FreeAndNil(lmfd); except on e: exception do begin if responseStream <> nil then FreeAndNil(responseStream); if lmfd <> nil then FreeAndNil(lmfd); end; end;

      

  • 相关阅读:
    OCP-1Z0-053-200题-125题-155
    OCP-1Z0-053-200题-127题-154答案貌似都不对?
    OCP-1Z0-053-200题-128题-281
    OCP-1Z0-053-200题-129题-153
    OCP-1Z0-053-200题-130题-288
    OCP-1Z0-053-200题-131题-152
    OCP-1Z0-053-200题-132题-272
    OCP-1Z0-053-200题-133题-151
    OCP-1Z0-053-200题-134题-4
    OCP-1Z0-053-200题-135题-150
  • 原文地址:https://www.cnblogs.com/iwana/p/13091211.html
Copyright © 2020-2023  润新知