Indy ads =每72个字符与Multipart表单数据Post

时间:2011-08-25 11:46:15

标签: delphi post delphi-xe indy multipartform-data

使用Delphi XE和Indy,我得到了一些提交到Web表单的代码。

idhttp := TidHttp.create;
postData := TIdMultiPartFormDataStream.Create;
try
    postData.AddFormField('name', edName.text);
    postData.AddFormField('email', edEmail.txt);
    postData.AddFormField('description', mDescription.text);

    idhttp.Request.ContentType := 'Content-Type: multipart/form-data; boundary=' + postData.Boundary;
    idhttp.fHttp.Post('http://www.example.com/contact.php', postData);

    ShowMessage('Thank you for your contact us.');
finally
    postData.Free;
    idHttp.Free;
end;

然而,当我在描述备忘录中输入类似的东西时。

This is a really long descriptie piece of text so we can see just how it's wrapping these lines and what it's doig to them I think it's making a hash of it.

Argh waht a pain.

我得到了

This is a really long descriptie piece of text so we can see just how =
it's wrapping these lines and what it's doig to them I think it's maki=
ng a hash of it.

Argh waht a pain.

所以对我来说似乎是自动换行,= 有线索的人吗?

2 个答案:

答案 0 :(得分:6)

你看到的是正确的行为。对于文本字段,TIdFormDataField.ContentTransfer属性默认为quoted-printable。这正是您所看到的编码类型。在quoted-printable中,后跟换行符的唯一=字符称为“软”中断。这就是MIME如何分解长行文本以适应各种协议(例如电子邮件)中的行长度限制。

您可以将ContentTransfer属性更改为以下任何支持的值:

  • 空白字符串
  • 7bit
  • 8bit
  • binary
  • quoted-printable
  • base64

如果您不希望对文字进行编码,请将ContentTransfer属性设置为quoted-printablebase64以外的任何值。

答案 1 :(得分:1)

它将这些内容编码为引用可打印的内容。您需要在显示它之前对其进行解码。