Correção upload usando hbtip

Projeto [x]Harbour - Compilador de código aberto compatível com o Clipper.

Moderador: Moderadores

Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 7929
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 1 vez

Correção upload usando hbtip

Mensagem por Itamar M. Lins Jr. »

Código: Selecionar todos

Hello,

While testing TIPClientHTTP to POST some data to a Web Server, I found a problem... If I POST text/plain data, it work fine as expected. But if I try to send a binary file, it will fail. Looking at TIP source, right at PostMultiPart method of TIPClientHTTP class, I found that the file reading method does not work with binary files.

The cBuf := FReadStr(nFile, @cBuf, nBuf) will fail only and when the read file is a binary one (pdf, zip, images, etc). Since FReadStr stops at CHR(0), it is not right for this kind of method, because the user can read any kind of file... am I right? This bug exists in xHarbour too.

In Harbour
contrib\hbtip\httpcli.prg

In xHarbour
source\tip\httpcln.prg

Best Regards

Alexandre Alencar
Aspec Informática

Código: Selecionar todos

2014-02-21 16:23 UTC+0100 Viktor Szakáts (vszakats users.noreply.github.com)
  * contrib/hbtip/httpcli.prg
    ! TIPClientHTTP():PostMultiPart() fixed to not RTE on various wrong
      input parameters passed via TIPClientHTTP():Attach()
    ! TIPClientHTTP():PostMultiPart() changed to use filename parsing
      core APIs instead of using local, non-portable implementation
    % TIPClientHTTP():PostMultiPart() optimizations (larger buffer, string
      building, loop, FOpen() mode, etc)
    ! TIPClientHTTP():PostMultiPart() fixed to always read in binary
      mode (callers' responsibility to configure mime-type correctly).
      See: https://groups.google.com/forum/#!topic/harbour-users/wOsubO8oifk
    ; (build tested only)
Penso que é uma importante correção.
Inclusive esse bug, conforme relatado tem no xHarbour também.

Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Responder