Meteor.http.post sets the lower case of the header. How do I override this?

I need to talk to a dummy web server that crashes while executing this code:

payload = JSON.stringify({
  jsonrpc: '2.0',
  method: 'sendMessage',
  id: 1,
  params: {
    accountID: 0,
    messageText: message,
    countDownTime: 0,
    interval: 0
  }
});
result = Meteor.http.post(api_endpoint, { content: payload });

After some debugging, I narrowed it down to the host header. The tcpdump of my request shows that a meteorite sends it in lowercase:

    0x0000:  4500 00dd f959 4000 4006 162b 0a01 0b58  E....Y@.@..+...X
    0x0010:  0a01 0b3d d6a5 1388 ae92 8657 3d7b 996e  ...=.......W={.n
    0x0020:  8018 01c9 2b66 0000 0101 080a 183e 7f02  ....+f.......>..
    0x0030:  34da 9ad8 504f 5354 202f 2048 5454 502f  4...POST./.HTTP/
    0x0040:  312e 310d 0a43 6f6e 7465 6e74 2d54 7970  1.1..Content-Typ
    0x0050:  653a 2061 7070 6c69 6361 7469 6f6e 2f78  e:.application/x
    0x0060:  2d77 7777 2d66 6f72 6d2d 7572 6c65 6e63  -www-form-urlenc
    0x0070:  6f64 6564 0d0a 5573 6572 2d41 6765 6e74  oded..User-Agent
    0x0080:  3a20 4d65 7465 6f72 0d0a 4163 6365 7074  :.Meteor..Accept
    0x0090:  3a20 2a2f 2a0d 0a68 6f73 743a 2031 302e  :.*/*..host:.10.
    0x00a0:  312e 3131 2e36 313a 3530 3030 0d0a 636f  1.11.61:5000..co
    0x00b0:  6e74 656e 742d 6c65 6e67 7468 3a20 3135  ntent-length:.15
    0x00c0:  310d 0a43 6f6e 6e65 6374 696f 6e3a 206b  1..Connection:.k
    0x00d0:  6565 702d 616c 6976 650d 0a0d 0a         eep-alive....

    0x0000:  4500 00cb f95a 4000 4006 163c 0a01 0b58  E....Z@.@..<...X
    0x0010:  0a01 0b3d d6a5 1388 ae92 8700 3d7b 996e  ...=........={.n
    0x0020:  8018 01c9 2b54 0000 0101 080a 183e 7f02  ....+T.......>..
    0x0030:  34da 9ad9 7b22 6a73 6f6e 7270 6322 3a22  4...{"jsonrpc":"
    0x0040:  322e 3022 2c22 6d65 7468 6f64 223a 2273  2.0","method":"s
    0x0050:  656e 644d 6573 7361 6765 222c 2269 6422  endMessage","id"
    0x0060:  3a31 2c22 7061 7261 6d73 223a 7b22 6163  :1,"params":{"ac
    0x0070:  636f 756e 7449 4422 3a30 2c22 6d65 7373  countID":0,"mess
    0x0080:  6167 6554 6578 7422 3a22 4974 2077 6173  ageText":"It.was
    0x0090:  2061 2064 6172 6b20 616e 6420 7374 6f72  .a.dark.and.stor
    0x00a0:  6d79 206e 6967 6874 2e22 2c22 636f 756e  my.night.","coun
    0x00b0:  7444 6f77 6e54 696d 6522 3a30 2c22 696e  tDownTime":0,"in
    0x00c0:  7465 7276 616c 223a 307d 7d              terval":0}}

And this server, apparently, checks only for the "Host" (case sensitive), and then gives an approval error if it cannot find it. Using curl, I confirmed that the same request completed successfully with a header. Unfortunately, fixing this bad behavior on a (patented) server is not an option, so I have to get the meteorite to send the expected values.

I already tried setting the header as follows:

result = Meteor.http.post(
  api_endpoint,
  { headers: { 'Host': instance.host }, content: payload }
);

- .

?

0.6.5.1.

+4
2

HTTP RFC 2616 , , .

, Meteor . Meteor XMLHttpRequest, . ( , jQuery, .)

Meteor Node, , , .

, , , , . , (, ) .

, , :

  • Meteor.call
  • / -
  • -

, !

+1

, API, , . Meteor.http HTTP.

, , (. ). , , .

, , HTTP-.

1) https://github.com/meteor/meteor/blob/devel/packages/http/

2) , , packages , HTTP

3) , 1 HTTP.

4) meteor add HTTP, HTTP .

5) httpcall_client.js 143 ( Meteor 0.6.5.1), , , .

+3

All Articles