K6 not sending http headers correctly

Hi I am having the following k6 code .

import http from ‘k6/http’;

export const paramsHighPriority = {
headers: {
‘3gpp-Sbi-Message-Priority’: 10
}
};

export const paramsLowPriority = {
headers: {
‘3gpp-Sbi-Message-Priority’: 25
}
};

export const options = {
discardResponseBodies: true,
scenarios: {
lowPriority: {
executor: ‘constant-vus’,
exec: ‘lowPriority’,
startTime: ‘0s’,
vus: 5,
duration: ‘3s’,
},
highPriority: {
executor: ‘constant-vus’,
exec: ‘highPriority’,
startTime: ‘0s’,
vus: 5,
duration: ‘3s’,
},
},
};

export function lowPriority() {
http.get(‘http://10.96.36.153:80/SccTestService/v1/id’, { headers:{ ‘3gpp-sbi-message-priority’: 10}});
}

export function highPriority() {
http.get(‘http://10.96.36.153:80/SccTestService/v1/id’);
}

however i could see the header 3gpp-sbi-message-priority is dropped

please advise on this thank you

I think this is just an issue with single quotes and you need double;

I hope this solves the issue for you;

import http from 'k6/http';

export const paramsHighPriority = {
  headers: {
    "3gpp-Sbi-Message-Priority": 10
  }
};

export const paramsLowPriority = {
  headers: {
    "3gpp-Sbi-Message-Priority": 25
  }
};

export const options = {
  discardResponseBodies: true,
  scenarios: {
    lowPriority: {
      executor: 'constant-vus',
      exec: 'lowPriority',
      startTime: '0s',
      vus: 5,
      duration: '3s',
    },
    highPriority: {
      executor: 'constant-vus',
      exec: 'highPriority',
      startTime: '0s',
      vus: 5,
      duration: '3s',
    },
  },
};

export function lowPriority() {
  http.get('http://10.96.36.153:80/SccTestService/v1/id', { headers: { "3gpp-Sbi-Message-Priority": 10 }});
}

export function highPriority() {
  http.get('http://10.96.36.153:80/SccTestService/v1/id');
}

1 Like

Hi @Prasanth. How can you tell the 3gpp-sbi-message-priority header is dropped?

I just did some testing locally (see attached screenshot) with your script and everything seems to work fine on my end.

Try running your test with the --http-debug="full" (i.e: k6 run k.js --http-debug="full") flag and monitor requests to check whether the header is being sent or no.

4 Likes

thank you it works .

1 Like