Skip to content

Commit 8de3017

Browse files
committed
fix: remove unecessary user-agent
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
1 parent 35a02b9 commit 8de3017

3 files changed

Lines changed: 9 additions & 23 deletions

File tree

services/apps/packages_worker/src/config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export function getNuGetConfig() {
7676
concurrency: parseInt(process.env.NUGET_FETCHER_CONCURRENCY ?? '20', 10),
7777
groupDelayMs: parseInt(process.env.NUGET_FETCHER_GROUP_DELAY_MS ?? '0', 10),
7878
isCritical: (process.env.NUGET_FETCHER_IS_CRITICAL ?? 'false') === 'true',
79-
userAgent: process.env.NUGET_USER_AGENT,
8079
}
8180
}
8281

services/apps/packages_worker/src/nuget/client.ts

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ interface ResolvedEndpoints {
2525

2626
let cachedEndpoints: ResolvedEndpoints | null = null
2727

28-
async function resolveEndpoints(userAgent?: string): Promise<ResolvedEndpoints> {
28+
async function resolveEndpoints(): Promise<ResolvedEndpoints> {
2929
if (cachedEndpoints) return cachedEndpoints
3030

3131
const resp = await axios.get<ServiceIndex>(SERVICE_INDEX_URL, {
32-
headers: userAgent ? { 'User-Agent': userAgent } : {},
3332
timeout: 10000,
3433
})
3534

@@ -68,9 +67,8 @@ function classifyError(err: unknown): NuGetFetchError | null {
6867

6968
export async function fetchSearch(
7069
packageId: string,
71-
userAgent?: string,
7270
): Promise<NuGetSearchItem | NuGetFetchError> {
73-
const { searchBaseUrl } = await resolveEndpoints(userAgent)
71+
const { searchBaseUrl } = await resolveEndpoints()
7472
const lowerPackageId = packageId.toLowerCase()
7573

7674
try {
@@ -82,7 +80,6 @@ export async function fetchSearch(
8280
take: 20,
8381
},
8482
headers: {
85-
...(userAgent ? { 'User-Agent': userAgent } : {}),
8683
'Accept-Encoding': 'gzip',
8784
},
8885
timeout: 15000,
@@ -100,35 +97,25 @@ export async function fetchSearch(
10097
}
10198
}
10299

103-
async function fetchRegistrationPage(
104-
pageId: string,
105-
userAgent?: string,
106-
): Promise<NuGetRegistrationPage> {
100+
async function fetchRegistrationPage(pageId: string): Promise<NuGetRegistrationPage> {
107101
const resp = await axios.get<NuGetRegistrationPage>(pageId, {
108-
headers: {
109-
...(userAgent ? { 'User-Agent': userAgent } : {}),
110-
'Accept-Encoding': 'gzip',
111-
},
102+
headers: { 'Accept-Encoding': 'gzip' },
112103
timeout: 15000,
113104
})
114105
return resp.data
115106
}
116107

117108
export async function fetchRegistration(
118109
packageId: string,
119-
userAgent?: string,
120110
): Promise<NuGetRegistrationIndex | NuGetFetchError> {
121-
const { registrationBaseUrl } = await resolveEndpoints(userAgent)
111+
const { registrationBaseUrl } = await resolveEndpoints()
122112
const lowerId = packageId.toLowerCase()
123113

124114
try {
125115
const resp = await axios.get<NuGetRegistrationIndex>(
126116
`${registrationBaseUrl}${lowerId}/index.json`,
127117
{
128-
headers: {
129-
...(userAgent ? { 'User-Agent': userAgent } : {}),
130-
'Accept-Encoding': 'gzip',
131-
},
118+
headers: { 'Accept-Encoding': 'gzip' },
132119
timeout: 15000,
133120
},
134121
)
@@ -139,7 +126,7 @@ export async function fetchRegistration(
139126
const page = index.items[i]
140127
if (!page.items) {
141128
try {
142-
const fullPage = await fetchRegistrationPage(page['@id'], userAgent)
129+
const fullPage = await fetchRegistrationPage(page['@id'])
143130
index.items[i] = { ...page, items: fullPage.items ?? [] }
144131
} catch {
145132
index.items[i] = { ...page, items: [] }

services/apps/packages_worker/src/nuget/runNuGetEnrichmentLoop.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ async function processPackage(
5656
const packageId = pkg.name
5757

5858
const [searchResult, registrationResult] = await Promise.all([
59-
fetchSearch(packageId, config.userAgent),
60-
fetchRegistration(packageId, config.userAgent),
59+
fetchSearch(packageId),
60+
fetchRegistration(packageId),
6161
])
6262

6363
if (isNuGetFetchError(registrationResult)) {

0 commit comments

Comments
 (0)