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

Smallest possible change to support POST with application/json body... #119

Closed

Conversation

nprbst
Copy link

@nprbst nprbst commented May 25, 2023

Necessary to make har-to-k6 useful for processing SPA and ReactNative type recordings...

@nprbst nprbst requested a review from a team as a code owner May 25, 2023 17:22
@nprbst nprbst requested review from going-confetti and maroparo and removed request for a team May 25, 2023 17:22
@CLAassistant
Copy link

CLAassistant commented May 25, 2023

CLA assistant check
All committers have signed the CLA.

Copy link

@maroparo maroparo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good!

@legander legander requested review from w1kman, EdvinasDaugirdas and maroparo and removed request for going-confetti and maroparo June 13, 2023 13:27
@EdvinasDaugirdas
Copy link
Contributor

Hey @nprbst, thank you for submitting a PR! Could you please provide more context why the change is needed and what's the desired outcome?

I've tried running the code with the following HAR (I assume that's the use case you want to support, let me know if I'm misunderstanding something):

{
  "log": {
    "entries": [
      {
        "index": 0,
        "comment": "POST data with percent-encoded name and value fields",
        "request": {
          "method": "POST",
          "url": "https://httpbin.test.k6.io/post",
          "headers": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ],
          "postData": {
            "mimeType": "application/json",
            "params": [
              {
                "name": "field",
                "value": "value"
              }
            ]
          }
        }
      }
    ]
  }
}

And the end result was:

import { sleep } from 'k6'
import http from 'k6/http'

export const options = {}

export default function main() {
  let response

  // POST data with percent-encoded name and value fields
  response = http.post('https://httpbin.test.k6.io/post', JSON.stringify(field), {
    headers: {
      'Content-Type': 'application/json',
    },
  })

  // Automatically added sleep
  sleep(1)
}

Spitted out k6 script wouldn't run, because field variable does not exist (it's taken from postData.params[0].name). So I'm a bit confused what's the desired outcome here.

@e-fisher
Copy link
Contributor

e-fisher commented Sep 4, 2023

Closing due to inactivity

@e-fisher e-fisher closed this Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants