guzzle / psr7

PSR-7 HTTP message library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Header validation (InvalidArgumentException : ":<header>" is not valid header name)

guram-vashakidze opened this issue · comments

Description
There aren't way to use "not valid" headers (which isn't follow RFC7230). In my app I'm implementing app push notification trough APNS. This API is using headers: :method, :path, :scheme.

Solutions

  1. Add option disable_header_validation - to disable assertHeader method
  2. Add option header_regex - to change default regex /^[a-zA-Z0-9\'#$%&*+.^_|~!-]+$/D`
  3. Add option header_validation - with closure which overwrite assertHeader method

Does their API work if you encode the : as %3A?

Actually, I think you are misunderstanding the spec you linked to. You are not supposed to add the :method etc headers as real headers. Those are pesudo-headers as part of HTTP/2. You need to set these values as the native method, path and schema on our request object, not as headers.

@GrahamCampbell Unfortunately these are the request headers not request body (also %3A - not working) - it's clear from their doc and I checked it.
I implement it on native cURL lib and it works.

Their doc says to use HTTP/2. cURL is for sure correcting your mistake and not using those as real headers for you.

If it's "not working", likely you need to instruct Guzzle to use HTTP/2. By default it will only use 1.0 or 1.1.