Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to send WebKitFormBoundary in multipart
#1
Exist some way to send WebKitFormBoundary with MultiPartFormDataStream?

My code without WebKitFormBoundary:
...
          idhttp1.Request.ContentType := MultiPartFormDataStream.RequestContentType;
          MultiPartFormDataStream.AddFormField('field1', var);
          MultiPartFormDataStream.AddFile('file1', link_foto_envio,
            GetMimeTypeFromFile(link_foto_envio));
          MultiPartFormDataStream.Position := 0;
          pagina := idhttp1.Post
            ('https://upload.myserver.com/', MultiPartFormDataStream);

...

Some idea?
Reply
#2
(08-03-2021, 04:58 PM)alpires2000 Wrote: Exist some way to send WebKitFormBoundary with MultiPartFormDataStream?

Not officially, but you could derive a new class from TIdMultipartFormDataStream in order to access its protected FBoundary and FRequestContentType members, and then you can set them to whatever you want. But, why do you think you need to customize the MIME boundary to use a WebKit format? TIdMultipartFormDataStream generates its own random MIME boundary (in '--------mmddyyhhnnsszzz' format), which should be perfectly fine as-is since the actual boundary used is included in the transmitted Content-Type HTTP header, and any conformant webserver will respect that boundary. So there is no good reason to change it.

(08-03-2021, 04:58 PM)alpires2000 Wrote: idhttp1.Request.ContentType := MultiPartFormDataStream.RequestContentType;

FYI, that line is not needed, as the TIdMultipartFormDataStream overload of TIdHTTP.Post() will handle that assignment internally for you.

(08-03-2021, 04:58 PM)alpires2000 Wrote: MultiPartFormDataStream.Position := 0;

That line is not necessary, either.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)