diff --git a/packages/bruno-app/src/components/ResponsePane/Timeline/index.js b/packages/bruno-app/src/components/ResponsePane/Timeline/index.js index d8a4770a5..326d96fe4 100644 --- a/packages/bruno-app/src/components/ResponsePane/Timeline/index.js +++ b/packages/bruno-app/src/components/ResponsePane/Timeline/index.js @@ -17,8 +17,6 @@ const Timeline = ({ request, response }) => { }); }); - let requestData = safeStringifyJSON(request.data); - return (
@@ -33,9 +31,9 @@ const Timeline = ({ request, response }) => { ); })} - {requestData ? ( + {request.data ? (
-            {'>'} data {requestData}
+            {'>'} data 
{request.data}
) : null}
diff --git a/packages/bruno-electron/src/ipc/network/interpolate-vars.js b/packages/bruno-electron/src/ipc/network/interpolate-vars.js index 0d95867b8..899b3d0f2 100644 --- a/packages/bruno-electron/src/ipc/network/interpolate-vars.js +++ b/packages/bruno-electron/src/ipc/network/interpolate-vars.js @@ -59,14 +59,6 @@ const interpolateVars = (request, envVars = {}, runtimeVariables = {}, processEn const contentType = getContentType(request.headers); if (contentType.includes('json')) { - if (typeof request.data === 'object') { - try { - let parsed = JSON.stringify(request.data); - parsed = _interpolate(parsed); - request.data = JSON.parse(parsed); - } catch (err) {} - } - if (typeof request.data === 'string') { if (request.data.length) { request.data = _interpolate(request.data); diff --git a/packages/bruno-electron/src/ipc/network/prepare-request.js b/packages/bruno-electron/src/ipc/network/prepare-request.js index 8a747f5d8..74cb85ac6 100644 --- a/packages/bruno-electron/src/ipc/network/prepare-request.js +++ b/packages/bruno-electron/src/ipc/network/prepare-request.js @@ -1,7 +1,6 @@ const os = require('os'); const { get, each, filter, extend, compact } = require('lodash'); const decomment = require('decomment'); -var JSONbig = require('json-bigint'); const FormData = require('form-data'); const fs = require('fs'); const path = require('path'); @@ -342,16 +341,10 @@ const prepareRequest = (item, collection) => { if (!contentTypeDefined) { axiosRequest.headers['content-type'] = 'application/json'; } - let jsonBody; try { - jsonBody = decomment(request?.body?.json); + axiosRequest.data = decomment(request?.body?.json); } catch (error) { - jsonBody = request?.body?.json; - } - try { - axiosRequest.data = JSONbig.parse(jsonBody); - } catch (error) { - axiosRequest.data = jsonBody; + axiosRequest.data = request?.body?.json; } } diff --git a/packages/bruno-js/src/bruno-request.js b/packages/bruno-js/src/bruno-request.js index 909adf92a..24af77598 100644 --- a/packages/bruno-js/src/bruno-request.js +++ b/packages/bruno-js/src/bruno-request.js @@ -56,11 +56,31 @@ class BrunoRequest { this.req.headers[name] = value; } - getBody() { + /** + * Get the body of the request + * + * @param {*} options + * @param {boolean} options.raw - If true, return the raw body without parsing it + * @returns + */ + getBody(options = {}) { + let headers = this.req.headers; + const contentType = headers?.['Content-Type'] || headers?.['content-type'] || ''; + const hasJSONContentType = contentType.includes('json'); + + if (hasJSONContentType && !options.raw) { + return JSON.parse(this.req.data); + } + return this.req.data; } setBody(data) { + if (typeof data === 'object') { + this.req.data = JSON.stringify(data); + return; + } + this.req.data = data; } diff --git a/packages/bruno-tests/collection/echo/echo bigint.bru b/packages/bruno-tests/collection/echo/echo bigint.bru new file mode 100644 index 000000000..32a6f145b --- /dev/null +++ b/packages/bruno-tests/collection/echo/echo bigint.bru @@ -0,0 +1,44 @@ +meta { + name: echo bigint + type: http + seq: 6 +} + +post { + url: {{host}}/api/echo/json + body: json + auth: none +} + +headers { + foo: bar +} + +auth:basic { + username: asd + password: j +} + +auth:bearer { + token: +} + +body:json { + { + "hello": 990531470713421825 + } +} + +body:text { + { + "hello": 990531470713421825 + } +} + +assert { + res.status: eq 200 +} + +script:pre-request { + bru.setVar("foo", "foo-world-2"); +}