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

Support for custom headers in mutipart form-data #180

Open
pmstss opened this issue Feb 17, 2023 · 0 comments
Open

Support for custom headers in mutipart form-data #180

pmstss opened this issue Feb 17, 2023 · 0 comments
Labels
Priority: low Type: enhancement New feature or request.

Comments

@pmstss
Copy link
Contributor

pmstss commented Feb 17, 2023

Description

According to OpenAPI 3.x specification, it's possible to specify custom headers for parts of multipart requests via EncodingObject.headers

Steps to reproduce

Pass the my-schema.yaml (see below) to the oas2har as follows:

import { oas2har } from '@har-sdk/oas';
import { readFile } from 'fs';
import { promisify } from 'util';
import { load } from 'js-yaml';

const content = await promisify(readFile)(
  './my-schema.yaml',
  'utf8'
);

const result = oas2har(load(content) as OpenAPIV3.Document);
my-schema.yaml
openapi: 3.0.1
info:
  title: Custom headers in multipart form-data
  version: 1.0.0
servers:
  - url: https://brightsec.com
paths:
  /upload:
    post:
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                image: {}
            encoding:
              image:
                contentType: image/png, image/jpeg
                headers:
                 X-Custom-Header:
                    schema:
                      type: string
        required: true
      responses:
        201:
          description: Successful upload
          content: {}

Actual result

Multipart form data in HAR entry postData doesn't include X-Custom-Header:

    "postData": {
      "mimeType": "multipart/form-data; boundary=956888039105887155673143",
      "text": "--956888039105887155673143\r\nContent-Disposition: form-data; name=\"image\"; filename=\"image\"\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: base64\r\n\r\niVBORw0KGgo=\r\n--9568880391058
87155673143--"
    }

Expected result

X-Custom-Header presents in postData

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: low Type: enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

2 participants