#1 2020-04-12 03:00:54

Eugene Ilyin
Member
From: milky_way/orion_arm/sun/earth
Registered: 2016-03-27
Posts: 132
Website

Customize HTTP 'Accept: */*' default header

Hi ab,

As for now both windows-related HTTP-client classes (TWinINet, TWinHTTP)
add hard-coded Accept: */* header in their InternalCreateRequest methods.

It's ok for most cases, but when I try to customize Accept header in my
GET / POST requests - the WinHTTP library append the new value
to this */* but not replace it.

As the result I'm unable to set Accept header to required exact value:
the */* prefix is always hardcoded.

  InHeaders := 'Accept: application/x-json-stream';
  ...Request(..., InHeaders, ...)

  Expected HTTP Packet header:

    Accept: application/x-json-stream

  Actual HTTP Packet header:

    Accept: */*, application/x-json-stream

To keep the full backward capability with the current implementation
the TWinHttpAPI.NoAllAccept property added to have an ability
to exlude this */* hardcoded value.

Please check pull request #307.

Last edited by Eugene Ilyin (2020-04-12 03:04:54)

Offline

#2 2020-04-17 04:51:52

Eugene Ilyin
Member
From: milky_way/orion_arm/sun/earth
Registered: 2016-03-27
Posts: 132
Website

Re: Customize HTTP 'Accept: */*' default header

Hi ab,
Do you need some assistance from my side to accept #307?

Offline

#3 2020-04-20 08:51:19

Eugene Ilyin
Member
From: milky_way/orion_arm/sun/earth
Registered: 2016-03-27
Posts: 132
Website

Re: Customize HTTP 'Accept: */*' default header

pull@request:~307$ tracert ab

Tracing route to Arnaud Bouchez [62.210.254.173]
over a maximum of 3 hops:

  1    72 ms    72 ms    72 ms  51.158.8.71
  2    72 ms    71 ms    71 ms  51.158.8.83
  3    67 ms    67 ms    67 ms  62-210-254-173.rev.poneytelecom.eu [62.210.254.173]

Trace complete.

Hm...

Offline

#4 2020-04-20 14:48:29

macfly
Member
From: Brasil
Registered: 2016-08-20
Posts: 374

Re: Customize HTTP 'Accept: */*' default header

Hi, Eugene,

Perhaps your pullrequest has not been merged, due to more things being changed than just addition of NoAllAccept property.

Do you need this modification to make "standalone" requests?

I believe the mORMot HTTP clients is not very flexible to be used outside the ORM.
Perhaps intentionally.

That's why I don't use it to access resources not related to the ORM. I use Delphi / FPC clients or SynCurl which are now a separate unit.

Offline

#5 2020-04-20 17:07:14

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,534
Website

Re: Customize HTTP 'Accept: */*' default header

+ for SynCurl

Offline

#6 2020-04-21 06:36:44

Eugene Ilyin
Member
From: milky_way/orion_arm/sun/earth
Registered: 2016-03-27
Posts: 132
Website

Re: Customize HTTP 'Accept: */*' default header

@macfly,

No, I think that issues is that ab is busy now with v2 migration.
No rush - just pinging him from time to time smile

#307 is fully backward capatible and solve 2 issues:
1. Hardcoded Accept: */*
2. Add QueryDataAvailable before ReadData (see separate forum topic ralated to it)

Both changes are minor (add couple of lines) and related only to Windows API.

I believe the mORMot HTTP clients is not very flexible to be used outside the ORM.

Let me disagree with you: mORMot HTTP Client Requests are good for feeds fetching and cancelling, cancellation of long requests, support of Brotli compression and many other applications compared to simple call of remote REST endpoint.

I can solve almost anything with inheritance, except hardcoded values or missing of QueryDataAvailable which is required.

#307 just fix this without any regression or changes in app code.

Offline

Board footer

Powered by FluxBB