View Issue Details

IDProjectCategoryView StatusLast Update
0032410FPCFCLpublic2017-09-20 22:30
ReporterAndrey ZubarevAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product VersionProduct Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0032410: EReadError in fphttpclient
Descriptionprogram vkerr;

{$mode objfpc} {$H+}

uses classes,fphttpclient;

var
  client:TFPHTTPClient;
  Response,Params:TStringList;

begin
  client:=TFPHTTPClient.Create(nil);
  client.AllowRedirect:=True;
  Response:=TStringList.Create;
  Params:=TStringList.Create;

  Params.Add('_origin=https://vk.com');
  client.FormPost('https://login.vk.com/',Params,Response);

  client.Free;
end.
TagsNo tags attached.
Fixed in Revision37269
FPCOldBugId
FPCTarget
Attached Files

Activities

Thaddy de Koning

2017-09-13 13:03

reporter   ~0102822

Last edited: 2017-09-13 13:11

View 3 revisions

This code does not work in any other language.
The response from https://login.vk.com is always missing...

Simply test it in your browser. (Remove the [^] first)
It also does not work with synapse (equivalent code).
It also does not work in Python (equivalent code).
It also does not work in Java (equivalent code).

And besides it also leaks memory: two stringlists.

So the read error is correct: nothing there...

Thaddy de Koning

2017-09-13 13:12

reporter   ~0102823

Last edited: 2017-09-13 13:13

View 2 revisions

Check the correct links first...I can't test against incorrect parameters any further than I did.

Andrey Zubarev

2017-09-13 17:29

reporter   ~0102825

No ansver - empty response. but why EReadError?

Synapse:

program vkerrsyn;

{$mode objfpc} {$H+}

uses classes,httpsend,ssl_openssl,synautil;

var
  Response:TMemoryStream;
  HTTP:THTTPSend;
  res:boolean;

begin
  Response:=TMemoryStream.Create;

  HTTP := THTTPSend.Create;
  WriteStrToStream(HTTP.Document, '_origin=https://vk.com');
  //HTTP.MimeType := 'application/x-www-form-urlencoded';
  res := HTTP.HTTPMethod('POST', 'https://login.vk.com/');
  if res then
    Response.CopyFrom(HTTP.Document, 0);
  HTTP.Free;
  Response.SaveToFile('c:\response.txt');
  Response.Free;
end.

Thaddy de Koning

2017-09-13 20:38

reporter   ~0102829

Last edited: 2017-09-13 20:43

View 3 revisions

Because there is nothing to read? That's what it is for...
The behavior is correct.
If you want I can attach the alternative code for synapse (pascal, a bit like yours) Python and Java I mentioned: it will always fail. You should handle the exception.

In synapse you check the response by result. In fphttp you check it by handling the exception.

Andrey Zubarev

2017-09-13 21:50

reporter   ~0102832

Even if You're right (I doubt it), it should be EEmptyResponse or something like, but not simply EReadError

Michael Van Canneyt

2017-09-20 16:47

administrator   ~0102947

Fixed, cause was a 302 redirect and not resetting the position of the input stream.
Thanks for reporting!

Andrey Zubarev

2017-09-20 22:30

reporter   ~0102956

Thanks!

Issue History

Date Modified Username Field Change
2017-09-12 23:00 Andrey Zubarev New Issue
2017-09-13 13:03 Thaddy de Koning Note Added: 0102822
2017-09-13 13:08 Thaddy de Koning Note Edited: 0102822 View Revisions
2017-09-13 13:11 Thaddy de Koning Note Edited: 0102822 View Revisions
2017-09-13 13:12 Thaddy de Koning Note Added: 0102823
2017-09-13 13:13 Thaddy de Koning Note Edited: 0102823 View Revisions
2017-09-13 17:29 Andrey Zubarev Note Added: 0102825
2017-09-13 20:38 Thaddy de Koning Note Added: 0102829
2017-09-13 20:40 Thaddy de Koning Note Edited: 0102829 View Revisions
2017-09-13 20:43 Thaddy de Koning Note Edited: 0102829 View Revisions
2017-09-13 21:50 Andrey Zubarev Note Added: 0102832
2017-09-15 13:35 Michael Van Canneyt Assigned To => Michael Van Canneyt
2017-09-15 13:35 Michael Van Canneyt Status new => assigned
2017-09-20 16:47 Michael Van Canneyt Fixed in Revision => 37269
2017-09-20 16:47 Michael Van Canneyt Note Added: 0102947
2017-09-20 16:47 Michael Van Canneyt Status assigned => resolved
2017-09-20 16:47 Michael Van Canneyt Fixed in Version => 3.1.1
2017-09-20 16:47 Michael Van Canneyt Resolution open => fixed
2017-09-20 16:47 Michael Van Canneyt Target Version => 3.2.0
2017-09-20 22:30 Andrey Zubarev Note Added: 0102956
2017-09-20 22:30 Andrey Zubarev Status resolved => closed