Kong / Kong/httpsnippet

Specifying file mime type for multipart requests using python requests module

Abierto
#302 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
1.2k
Forks
242
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I'm unable to specify the mime type of the files sent as part of `multipart/form-data` requests using the python requests module.

I believe the relevant code is here: https://github.com/Kong/httpsnippet/blob/master/src/targets/python/requests/client.ts#L82

I was thinking we could support it by making a change like so:

```javascript
if (p.fileName) {
if (p.mimeType) {
files[p.name] = `('${p.fileName}', open('${p.fileName}', 'rb'), '${p.mimeType}')`;
} else {
// current behaviour
files[p.name] = `open('${p.fileName}', 'rb')`;
}
hasFiles = true;
} else {
payload[p.name] = p.value;
hasPayload = true;
}
```

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Start in src/targets/python/requests/client.ts around line 82 and inspect how multipart files are assembled for Python requests snippets. Compare the current file handling with the proposed MIME-type behavior, then check nearby tests or target fixtures if present. Done means a file parameter with a MIME type produces the requested multipart tuple while existing file and payload handling remains unchanged.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python, typescript
Área
api, tooling
Tipo de issue
Nueva funcionalidad
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.