communication with httpSocket

I had hard times getting the following thing solved: Send a pdf-file to an URL, where it will be transferred to text and also parsed.

Partly I followed the instructions from
but unfortunately it wouldn’t work.

To find out what it was I included httpsocket.yield, so that other commands would be possible as the program was waiting for the reply.

And from this moment on it worked fluently.

here the code: (Buttonaction:)

[code] Dim pdffile As FolderItem = GetOpenFolderItem("")
DIM response as string
dim Httpror as integer
Dim httpxy As New HTTPSocket
Dim HTMLForm As New Dictionary
HTMLForm.Value(“file”) = pdffile
SetFormData(httpxy, HTMLForm, “”) ’ pass an empty boundary to generate a new one
response = DefineEncoding(httpxy.Post(“URLwhereToCommunicate”, 40), Encodings.UTF8)


and the SUB SetFormData

[code] If Boundary.Trim = “” Then
Boundary = “0x” + Left(EncodeHex(MD5(Format(Microseconds, “############.##########”))) + “00000000000000000000000000000000”, 32) + “bOuNdArY”
End If
Dim data As New MemoryBlock(0)
Dim out As New BinaryStream(data)

For Each key As String In FormData.Keys
out.Write("–" + Boundary + EndOfLine)
If VarType(FormData.Value(Key)) = Variant.TypeString Then
out.Write(“Content-Disposition: form-data; name=”"" + key + “”"" + EndOfLine + EndOfLine)
out.Write(FormData.Value(key) + EndOfLine)
ElseIf FormData.Value(Key) IsA FolderItem Then
Dim file As FolderItem = FormData.Value(key)
out.Write(“Content-Disposition: form-data; name=”"" + key + “”"; filename=""" + File.Name + “”"" + EndOfLine)
out.Write(“Content-Type: application/pdf” + EndOfLine + EndOfLine) ’ replace with actual MIME Type
Dim bs As BinaryStream = BinaryStream.Open(File)
out.Write(bs.Read(bs.Length) + EndOfLine)
End If
out.Write("–" + Boundary + “–” + EndOfLine)

sock.SetRequestContent(data, “multipart/form-data; boundary=” + Boundary)