Отправить составной файл без имени файла - PullRequest
1 голос
/ 12 марта 2020

Я хотел бы отправить составной файл без имени файла , используя Каратэ DSL, но какой-то механизм внутри Каратэ DSL автоматически устанавливает имя файла

Функция # 1

Feature: Send file without filename

Background:
* url 'http://localhost'
* configure proxy = 'http://localhost:8080'
* configure ssl = { "trustAll": true }

Scenario:
    Given path '/upload'
    And multipart field REQUEST = 'Hello world'
    And header Content-Type = 'multipart/form-data'
    And multipart file myfile.bin = { value: 'Hello world from file', contentType: application/octet-stream }
    When method POST
    Then status 200

Установка значения no или даже пустого атрибута имени файла по-прежнему приводит к

Content-Disposition: form-data; Name = "myfile.bin"; filename = "myfile.bin"

Feature # 2

Feature: Send file without filename

Background:
* url 'http://localhost'
* configure proxy = 'http://localhost:8080'
* configure ssl = { "trustAll": true }

Scenario:
    Given path '/upload'
    And multipart field REQUEST = 'Hello world'
    And header Content-Type = 'multipart/form-data'
    And multipart file myfile.bin = { value: 'Hello world from file', contentType: application/octet-stream, filename: '' }
    When method POST
    Then status 200

Feature # 3

Feature: Send file without filename

Background:
* url 'http://localhost'
* configure proxy = 'http://localhost:8080'
* configure ssl = { "trustAll": true }

Scenario:
    Given path '/upload'
    And multipart field REQUEST = 'Hello world'
    And header Content-Type = 'multipart/form-data'
    And multipart file myfile.bin = { value: 'Hello world from file', contentType: application/octet-stream, filename: '#(null)' }
    When method POST
    Then status 200

Ответы, полученные с помощью mitmproxweb

Feature # 1: Снимок экрана из mitmproxweb (без указания имени файла)

Feature # 2: Снимок экрана из mitmproxweb (с указанием пустого имени файла)

Feature # 3: Снимок экрана из mitmproxweb (с указанием пустого имени в качестве имени файла)

1 Ответ

0 голосов
/ 12 марта 2020

Вы можете попробовать multipart entity - это разработано, чтобы не устанавливать имя.

Наконец, если это не работает, вы можете прибегнуть к созданию необработанной полезной нагрузки, как описано здесь: https://github.com/intuit/karate/issues/921#issuecomment -544161221 - но не забудьте внести исправление (или пример , который помогает нам исправить).

...