cf-abacus icon indicating copy to clipboard operation
cf-abacus copied to clipboard

Add custom header in the batch request

Open wanglw opened this issue 5 years ago • 6 comments

wanglw avatar Nov 01 '18 08:11 wanglw

Hey wanglw!

Thanks for submitting this pull request!

All pull request submitters and commit authors must have a Contributor License Agreement (CLA) on-file with us. Please have everyone sign the appropriate CLA (individual or corporate), and send to: [email protected].

When sending a signed CLA please provide your github username in case of an individual CLA or the list of github usernames that can make pull requests on behalf of your organization.

The following github user @wanglw has not signed the appropriate CLA.

If you are confident that everyone listed is covered under a Corporate CLA, please make sure everyone has publicized their membership in the appropriate Github Org, per these instructions.

Once everyone has publicized their membership, one of the owners of this repository can close and reopen this pull request, and dreddbot will take another look.

cfdreddbot avatar Nov 01 '18 08:11 cfdreddbot

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/161644021

The labels on this github issue will be updated when the story is started.

cf-gitbot avatar Nov 01 '18 08:11 cf-gitbot

Codecov Report

Merging #1097 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1097   +/-   ##
=======================================
  Coverage   95.21%   95.21%           
=======================================
  Files         126      126           
  Lines        3509     3509           
=======================================
  Hits         3341     3341           
  Misses        168      168

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a48be75...5a6b2c7. Read the comment docs.

codecov[bot] avatar Nov 01 '18 08:11 codecov[bot]

Can you please point out how adding customHeader works? Is this handled by request or express module?

hsiliev avatar Nov 01 '18 15:11 hsiliev

@hsiliev Based on my understanding, I think it is handled by request.

Code level: In our example, we get the customHeader in our code like this:

var myHeader = req.customHeader["if-match"] ? req.customHeader["if-match"] : "";

Example: POST http://localhost:11443/batch body includes the customeHeader:

[
    {
        "method": "PUT",
        "uri": "XXXXXXXX",
        "body": {
        	"test_id": "TEST",
        	"state": "test"
        },
        "headers": {
        	"if-match": "7-0b6a49e921a6a9214a5503e29adcc7eb"
        }
    }
]

wanglw avatar Nov 22 '18 09:11 wanglw

I don't see customHeader in the source of request (nor in express) and that's why I asked.

In fact the docs mention only headers option (https://github.com/request/request#custom-http-headers), so I think the change should actually be:

headers: r.headers

hsiliev avatar Nov 22 '18 14:11 hsiliev