{"id":13342904,"url":"https://github.com/gpiechnik2/xk6-proxy","last_synced_at":"2026-01-19T22:10:55.044Z","repository":{"id":57706007,"uuid":"501429984","full_name":"gpiechnik2/xk6-proxy","owner":"gpiechnik2","description":"k6 extension to define a separate (independent) proxy from the HTTP_PROXY variables for HTTP requests. Additionally, the extension allows to display and re-set a new proxy in tests. Implemented using the xk6 system.","archived":false,"fork":false,"pushed_at":"2023-07-18T22:43:12.000Z","size":40,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-07-30T21:05:38.294Z","etag":null,"topics":["extension","k6","performance","proxy","tests","xk6","xk6-extension"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gpiechnik2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-08T22:31:14.000Z","updated_at":"2024-05-22T19:48:28.000Z","dependencies_parsed_at":"2024-06-20T00:14:14.133Z","dependency_job_id":"eb798833-6985-42fe-9c2e-b92c791ae439","html_url":"https://github.com/gpiechnik2/xk6-proxy","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpiechnik2%2Fxk6-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpiechnik2%2Fxk6-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpiechnik2%2Fxk6-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gpiechnik2%2Fxk6-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gpiechnik2","download_url":"https://codeload.github.com/gpiechnik2/xk6-proxy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221265583,"owners_count":16788059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extension","k6","performance","proxy","tests","xk6","xk6-extension"],"created_at":"2024-07-29T19:30:06.818Z","updated_at":"2026-01-19T22:10:55.038Z","avatar_url":"https://github.com/gpiechnik2.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xk6-proxy\n[k6](https://github.com/grafana/k6) extension to define a separate (independent) proxy from the HTTP_PROXY variables for HTTP requests. Additionally, the extension allows to display and re-set a new proxy in tests. Implemented using the\n[xk6](https://github.com/grafana/xk6) system.\n\n## Build\n```shell\nxk6 build --with github.com/gpiechnik2/xk6-proxy@latest\n```\n\n## Example\n\n### On a single request\nTo use the proxy on http.Request objects from the k6 repository you would have to rebuild the entire class. Since this would take too much time, we use requests from the library, which under the k6 implementation is also used. We do not return the same Response object, but instead a string with the typical response for the http format.\n\n```javascript\nimport proxy from 'k6/x/proxy';\n\n\nexport default function () {\n    const proxyRes = proxy.request('GET', 'https://k6.io', \"http://0.0.0.0:8080\", {\n        headers: [\n            {\n                'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0',\n                'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'\n            }\n        ]\n    });\n\n    check(proxyRes, {\n        'response code was 200': (proxyRes) =\u003e proxyRes.includes(\"200 OK\") == true\n    });\n}\n```\n\n### On global variables\n**[WARNING]** Remember that using global variables affects ALL runs. The example at the bottom should not be used in performing actual tests. Use only for debugging or on a single thread.\n\n```javascript\nimport proxy from 'k6/x/proxy';\n\n\nexport default function () {\n    let currentEnvHTTP = proxy.getCurrentEnvHTTP() // 0.0.0.0:9000\n    let currentEnvHTTPS = proxy.getCurrentEnvHTTPS() // 0.0.0.0:6000\n    \n    proxy.setEnvHTTP('0.0.0.0:14000') // set a new HTTP_PROXY environment variable\n    proxy.setEnvHTTPS('0.0.0.0:10000') // set a new HTTPS_PROXY environment variable\n\n    currentEnvHTTP = proxy.getCurrentEnvHTTP() // 0.0.0.0:14000\n    currentEnvHTTPS = proxy.getCurrentEnvHTTPS() // 0.0.0.0:10000\n}\n```\n\n## Run sample script\n```shell\n./k6 run ./script.js\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgpiechnik2%2Fxk6-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgpiechnik2%2Fxk6-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgpiechnik2%2Fxk6-proxy/lists"}