/** * Could be called by sync or by async framework * */ public function execute() { try { // clear any old values, in case we don't populate them on this request $this->rawResponse = null; $this->instResponse = null; $this->autoExec = null; $expectBinary = $this->prepareBinaryResponseAsDownload(); $this->rawResponse = WorkbenchContext::get()->getRestDataConnection()->send($this->requestMethod, $this->url, explode("\n", $this->requestHeaders), in_array($this->requestMethod, RestApiClient::getMethodsWithBodies()) ? $this->requestBody : null, $expectBinary); if (stripos($this->rawResponse->header, "HTTP/1.1 404") !== false) { $this->showResponse = false; throw new WorkbenchHandledException("Service not found at: " . $this->url); } if (stripos($this->rawResponse->header, "Content-Type: text/html") !== false) { $this->showResponse = false; throw new WorkbenchHandledException("Got HTML at: " . $this->url); } else { if ($expectBinary) { return; } else { if (stripos($this->rawResponse->header, "Content-Type: application/json") !== false) { $insturmenter = new RestResponseInstrumenter(htmlspecialchars($this->pageSelf)); $this->instResponse = $insturmenter->instrumentJson($this->rawResponse->body); $this->showResponse = true; } else { $this->showResponse = true; } } } } catch (Exception $e) { $this->errors = $e->getMessage(); } }
function establish(ConnectionConfiguration $connConfig) { $restConnection = new RestApiClient($this->buildEndpoint($connConfig), $connConfig->getSessionId()); $restConnection->setCompressionEnabled(WorkbenchConfig::get()->value("enableGzip")); $restConnection->setUserAgent(getWorkbenchUserAgent()); $restConnection->setExternalLogReference($_SESSION['restDebugLog']); //TODO: maybe replace w/ its own log?? //TODO: move into ctx $restConnection->setLoggingEnabled(WorkbenchConfig::get()->value("debug") == true); $restConnection->setProxySettings(getProxySettings()); $restConnection->setIncludeSessionCookie(WorkbenchConfig::get()->value("includeSessionCookie")); return $restConnection; }
<strong>Request Headers</strong> </p> <textarea id="requestHeaders" name="requestHeaders" style="width: 100%; height: 4em; font-family: courier, monotype;"><?php echo htmlspecialchars($c->requestHeaders); ?> </textarea> <a id="requestHeadersDefaulter" class="miniLink pseudoLink" style="float: right;" onClick="document.getElementById('requestHeaders').value='<?php echo str_replace("\n", "\\n", $c->getDefaultRequestHeaders()); ?> ';">Restore Default Headers</a> <br/> </div> <div id="requestBodyContainer" style="display: <?php echo in_array($c->requestMethod, RestApiClient::getMethodsWithBodies()) ? 'inline' : 'none'; ?> ;"> <p> <strong>Request Body</strong> </p> <textarea name="requestBody" style="width: 100%; height: 10em; font-family: courier, monotype;"><?php echo htmlspecialchars($c->requestBody); ?> </textarea> <br/> </div> </form> <p />