Hi,

I have a scenario where I need to login to some web app and then reuse the
session/cookies in further requests.

The basic approach (as presented in Enterprise Pharo book) works just fine

client := ZnClient new.

client
url: 'http://example.com/login';
formAt: 'username' put: 'john....@acme.com';
formAt: 'password' put: 'trustno1';
post.

client
get: 'http://example.com/my-file'.

The problem is when I want to change the way response is retrieved. E.g.

client
accept: 'text/json';
contentReader: [ :entity | STON fromString: entity contents ];
get: 'http://example.com/some.json'.

"uh-oh... it still uses STON contentReader"
client
get: 'http://example.com/homepage.html'


Of course I could manually copy all the cookies, however I imagine there is
a better approach. Maybe injecting session from one ZnClient instance to
another?

Thanks,
Peter

Reply via email to