Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ FEATURE ] Client Object #6

Open
saniyar-dev opened this issue Feb 25, 2025 · 0 comments
Open

[ FEATURE ] Client Object #6

saniyar-dev opened this issue Feb 25, 2025 · 0 comments

Comments

@saniyar-dev
Copy link

saniyar-dev commented Feb 25, 2025

Is your feature request related to a problem? Please describe.
Yes, we want to implement Client object as it's explained in this design document.

Some examples would be:

  • Default client used to make requests:
import { Client } from 'k6/x/net/http';

export default async function () {
  const client = new Client();
  const response = await client.get('https://httpbin.test.k6.io/get');
  const jsonData = await response.json();
  console.log(jsonData);
}
  • Creating a client with custom transport settings, some HTTP options, and making a POST request:
import { TCP } from 'k6/x/net';
import { Client } from 'k6/x/net/http';

export default async function () {
  const client = new Client({
    dial: async address => {
      return await TCP.open(address, { keepAlive: true });
    },
    proxy: 'https://myproxy',
    headers: { 'User-Agent': 'k6' },  // set some global headers
  });
  await client.post('http://10.0.0.10/post', {
    json: { name: 'k6' }, // automatically adds 'Content-Type: application/json' header
  });
}
  • etc.

why we have this issue?

This issue will track the progress of Client object being implemented and it will be updated as we continue to develop new features on it, any further feature requests for Client object should be addressed here too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant