"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "helpers/codegen/generators/php-curl.js" between
hoppscotch-2.0.0.tar.gz and hoppscotch-2.1.0.tar.gz

About: Hoppscotch is a light-weight, web based API development suite.

php-curl.js  (hoppscotch-2.0.0):php-curl.js  (hoppscotch-2.1.0)
skipping to change at line 28 skipping to change at line 28
rawRequestBody, rawRequestBody,
contentType, contentType,
headers, headers,
}) => { }) => {
const requestString = [] const requestString = []
const genHeaders = [] const genHeaders = []
requestString.push(`<?php\n`) requestString.push(`<?php\n`)
requestString.push(`$curl = curl_init();\n`) requestString.push(`$curl = curl_init();\n`)
requestString.push(`curl_setopt_array($curl, array(\n`) requestString.push(`curl_setopt_array($curl, array(\n`)
requestString.push(` CURLOPT_URL => "${url}${pathName}${queryString}",\n`) requestString.push(` CURLOPT_URL => "${url}${pathName}?${queryString}",\n`)
requestString.push(` CURLOPT_RETURNTRANSFER => true,\n`) requestString.push(` CURLOPT_RETURNTRANSFER => true,\n`)
requestString.push(` CURLOPT_ENCODING => "",\n`) requestString.push(` CURLOPT_ENCODING => "",\n`)
requestString.push(` CURLOPT_MAXREDIRS => 10,\n`) requestString.push(` CURLOPT_MAXREDIRS => 10,\n`)
requestString.push(` CURLOPT_TIMEOUT => 0,\n`) requestString.push(` CURLOPT_TIMEOUT => 0,\n`)
requestString.push(` CURLOPT_FOLLOWLOCATION => true,\n`) requestString.push(` CURLOPT_FOLLOWLOCATION => true,\n`)
requestString.push(` CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n`) requestString.push(` CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\n`)
requestString.push(` CURLOPT_CUSTOMREQUEST => "${method}",\n`) requestString.push(` CURLOPT_CUSTOMREQUEST => "${method}",\n`)
if (auth === "Basic Auth") { if (auth === "Basic Auth") {
const basic = `${httpUser}:${httpPassword}` const basic = `${httpUser}:${httpPassword}`
skipping to change at line 67 skipping to change at line 67
const parts = requestBody.replace(toRemove, "").replace(toReplace, "=>") const parts = requestBody.replace(toRemove, "").replace(toReplace, "=>")
requestBody = `array(${parts})` requestBody = `array(${parts})`
} else if (isJSONContentType(contentType)) { } else if (isJSONContentType(contentType)) {
requestBody = JSON.stringify(requestBody) requestBody = JSON.stringify(requestBody)
} else if (contentType.includes("x-www-form-urlencoded")) { } else if (contentType.includes("x-www-form-urlencoded")) {
if (requestBody.includes("=")) { if (requestBody.includes("=")) {
requestBody = `"${requestBody}"` requestBody = `"${requestBody}"`
} else { } else {
const requestObject = JSON.parse(requestBody) const requestObject = JSON.parse(requestBody)
requestBody = `"${Object.keys(requestObject) requestBody = `"${Object.keys(requestObject)
.map((key) => `${key}=${requestObject[key].toString()}`) .map((key) => `${key}=${requestObject[key]}`)
.join("&")}"` .join("&")}"`
} }
} }
if (contentType) { if (contentType) {
genHeaders.push(` "Content-Type: ${contentType}; charset=utf-8",\n`) genHeaders.push(` "Content-Type: ${contentType}; charset=utf-8",\n`)
} }
requestString.push(` CURLOPT_POSTFIELDS => ${requestBody},\n`) requestString.push(` CURLOPT_POSTFIELDS => ${requestBody},\n`)
} }
if (headers.length > 0) { if (headers.length > 0) {
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)