elasticsearch-php icon indicating copy to clipboard operation
elasticsearch-php copied to clipboard

host vs. Host

Open kristofvc opened this issue 9 years ago • 2 comments

Summary of problem or feature request

When adding a host in the elasticsearch library it's added with a lowercase h, like "host" to the headers. Other packages like php-vcr add the host with an uppercase H, like "Host".

Thus when using elasticsearch in combination with php-vcr we have two host headers, which returns a 400. I'm logging this issue here because it seems that "Host" with an uppercase H, is widely seen as the standard header.

System details

  • Ubuntu 14.04.5
  • 7.0
  • 5.2
  • 5.5

kristofvc avatar Aug 08 '17 13:08 kristofvc

Hi @kristofvc the RFC 7230 says that


   Each header field consists of a case-insensitive field name followed
   by a colon (":"), optional leading whitespace, the field value, and
   optional trailing whitespace.```

In this case Host == host
I think we should investigate elasticsearch-php consider the case or not for the http 
headers part. Otherwise it's a problem of the other library


p365labs avatar Aug 10 '17 15:08 p365labs

Huh. Well, I have no problem changing to capital H if it makes life easier. Because the spec says it should be case-insensitive, it doesn't break anything. And a quick skim does seem to suggest that if a server/browser might break, it'd be with lowercase headers.

I'll make the change in a sec :)

polyfractal avatar Aug 10 '17 19:08 polyfractal