Test the deployed endpoint with a GET request.
345734
def touch_endpoint(self, endpoint_url):
        

        # Private APIGW endpoints most likely can't be reached by a deployer
        # unless they're connected to the VPC by VPN. Instead of trying
        # connect to the service, print a warning and let the user know
        # to check it manually.
        # See: https://github.com/Miserlou/Zappa/pull/1719#issuecomment-471341565
        if 'PRIVATE' in self.stage_config.get('endpoint_configuration', []):
            print(
                click.style("Warning!", fg="yellow", bold=True) +
                " Since you're deploying a private API Gateway endpoint,"
                " Zappa cannot determine if your function is returning "
                " a correct status code. You should check your API's response"
                " manually before considering this deployment complete."
            )
            return

        touch_path = self.stage_config.get('touch_path', '/')
        req = requests.get(endpoint_url + touch_path)

        # Sometimes on really large packages, it can take 60-90 secs to be
        # ready and requests will return 504 status_code until ready.
        # So, if we get a 504 status code, rerun the request up to 4 times or
        # until we don't get a 504 error
        if req.status_code == 504:
            i = 0
            status_code = 504
            while status_code == 504 and i <= 4:
                req = requests.get(endpoint_url + touch_path)
                status_code = req.status_code
                i += 1

        if req.status_code >= 500:
            raise ClickException(click.style("Warning!", fg="red", bold=True) +
                " Status check on the deployed lambda failed." +
                " A GET request to '" + touch_path + "' yielded a " +
                click.style(str(req.status_code), fg="red", bold=True) + " response code.")
871330
def _get(self, url):
        """"""
        self.logger.info(f'Sending request: {RequestHandler.BASE_URL+url}')
        req = requests.get(RequestHandler.BASE_URL+url, headers=self.headers)
        self.logger.info(f'Request returned with status code {req.status_code}')

        if req.status_code == requests.codes.ok:
            return req

        if req.status_code == requests.codes.bad:
            raise APIErrorException('Invalid request. Check parameters.', req.status_code)

        if req.status_code == requests.codes.forbidden:
            raise APIErrorException('This resource is restricted', req.status_code)

        if req.status_code == requests.codes.not_found:
            raise APIErrorException('This resource does not exist. Check parameters', req.status_code)

        if req.status_code == requests.codes.too_many_requests:
            raise APIErrorException('You have exceeded your allowed requests per minute/day', req.status_code)
544475
def _get_response(self, endpoint, query, is_post=False):
        """"""
        timeout_secs = self._settings.get('timeout', 10)
        headers = self._settings.get('request_headers', {})
        try:
            if is_post:
                response = requests.post(
                    endpoint, data=query, headers=headers, timeout=timeout_secs)
            else:
                response = requests.get(
                    endpoint, params=query, headers=headers, timeout=timeout_secs)
        except requests.exceptions.Timeout as e:
            raise Exception(
                'API request timed out after %s seconds.' % timeout_secs)
        except Exception as e:
            raise e

        if response.status_code != 200:
            raise Exception('Received status code %s from %s. Content is:\n%s'
                            % (response.status_code,
                               self.get_service_name(),
                               response.text))
        return response
70264
def rest_get(url, timeout, show_error=False):
    ''''''
    try:
        response = requests.get(url, timeout=timeout)
        return response
    except Exception as exception:
        if show_error:
            print_error(exception)
        return None
1308861
async def request(
            self,
            method: str,
            endpoint: str,
            *,
            base_url: str = API_URL_SCAFFOLD,
            headers: dict = None,
            params: dict = None,
            json: dict = None) -> dict:
        """"""
        if not headers:
            headers = {}
        headers.update({'Content-Type': 'application/json'})

        if not params:
            params = {}

        if self._api_key:
            params.update({'key': self._api_key})

        url = '{0}/{1}'.format(base_url, endpoint)
        async with self.websession.request(method, url, headers=headers,
                                           params=params, json=json) as resp:
            data = await resp.json(content_type=None)
            _raise_on_error(data)
            return data
1053910
public String get(String endpoint, String params) throws IOException {
        return this.get(endpoint, params, null);
    }
595615
def do_GET(self):
        
        if self.path.endswith("http_manifest.json"):
            try:
                manifest = self.generate_http_manifest()
                self.send_response(200)
                self.end_headers()
                self.wfile.write(manifest)
            except dtoolcore.DtoolCoreTypeError:
                self.send_response(400)
                self.end_headers()

        else:
            super(DtoolHTTPRequestHandler, self).do_GET()
1215484
def _request(self, path, method, body=None):
        """"""
        url = '/'.join([_SERVER, path])
        (resp, content) = _HTTP.request(url, method,
                                        headers=self._headers, body=body)

        content_type = resp.get('content-type')
        if content_type and content_type.startswith('application/json'):
            content = json.loads(content.decode('UTF-8'))

        return (resp, content)
391222
def render_GET(self, request):
    """"""
    fullPath = request.path.split('/')
    if not fullPath[-1]:
      fullPath = fullPath[:-1]
    parts = fullPath[2:]
    statDict = util.lookup(scales.getStats(), parts)

    if statDict is None:
      request.setResponseCode(404)
      return "Path not found."

    if 'query' in request.args:
      query = request.args['query'][0]
    else:
      query = None

    if 'format' in request.args and request.args['format'][0] == 'json':
      request.headers['content-type'] = 'text/javascript; charset=UTF-8'
      formats.jsonFormat(request, statDict, query)
    elif 'format' in request.args and request.args['format'][0] == 'prettyjson':
      request.headers['content-type'] = 'text/javascript; charset=UTF-8'
      formats.jsonFormat(request, statDict, query, pretty=True)
    else:
      formats.htmlHeader(request, '/' + '/'.join(parts), self.serverName, query)
      formats.htmlFormat(request, tuple(parts), statDict, query)

    return ''
693794
def verify_endpoint_url(web_url)
      begin
        resource = RestClient::Resource.new web_url
        resource.get
      rescue RestClient::Exception => e
        if e.http_code == 404
          set_valid(false)
        end
      end
    end
1363611
def _construct_request(self):
        
        if self.parsed_endpoint.scheme == 'https':
            conn = httplib.HTTPSConnection(self.parsed_endpoint.netloc)
        else:
            conn = httplib.HTTPConnection(self.parsed_endpoint.netloc)
        head = {
            "Accept": "application/json",
            "User-Agent": USER_AGENT,
            API_TOKEN_HEADER_NAME: self.api_token,
        }
        if self.api_version in ['0.1', '0.01a']:
            head[API_VERSION_HEADER_NAME] = self.api_version
        return conn, head
156653
def do_GET(self):
        """"""
        logging.debug("New GET request.")

        query = parse_qs(urlparse(self.path).query)
        command = query['command'][0].split(' ')
        async = bool(int(query.get('async', [False])[0]))
        output = run_command(command, asynchronous=async)

        self.respond(output)
1183440
def api_call(endpoint, args, payload):
    
    headers = {'content-type': 'application/json; ; charset=utf-8'}
    url = 'https://{}/{}'.format(args['--server'], endpoint)
    attempt = 0
    resp = None

    while True:
        try:
            attempt += 1
            resp = requests.post(
                url, data=json.dumps(payload), headers=headers,
                verify=args['--cacert']
            )
            resp.raise_for_status()
            break
        except (socket_timeout, requests.Timeout,
                requests.ConnectionError, requests.URLRequired) as ex:
            abort('{}'.format(ex))
        except requests.HTTPError as ex:
            warn('Requests HTTP error: {}'.format(ex))
            if attempt >= 5:
                abort('Too many HTTP errors.')
    if resp is not None:
        try:
            return resp.json()
        except ValueError:
            abort('Unexpected response from server:\n\n{}'.format(resp.text))
    else:
        abort("Couldn't POST to Red October")
573140
async def _request(
            self,
            method: str,
            endpoint: str,
            *,
            headers: dict = None,
            params: dict = None,
            json: dict = None,
            ssl: bool = True) -> dict:
        """"""
        return await self._client_request(
            method,
            '{0}/{1}'.format(self._host, endpoint),
            access_token=self._access_token,
            access_token_expiration=self._access_token_expiration,
            headers=headers,
            params=params,
            json=json,
            ssl=ssl)
659738
def send_get_command(self, command):
        """"""
        # Send commands via HTTP get
        res = requests.get("http://{host}:{port}{command}".format(
            host=self._host, port=self._receiver_port, command=command),
                           timeout=self.timeout)
        if res.status_code == 200:
            return True
        else:
            _LOGGER.error((
                "Host %s returned HTTP status code %s to GET command at "
                "end point %s"), self._host, res.status_code, command)
            return False
864606
def fetch(self, endpoint, data = None):
        
        payload = {
            "lastServerChangeId": "-1",
            "csrf": self.__csrf,
            "apiClient": "WEB"
        }
        if data is not None:
            payload.update(data)

        return self.post(endpoint, payload)
412184
def post(self, endpoint, params=None, version='1.1', json_encoded=False):
        """"""
        return self.request(endpoint, 'POST', params=params, version=version, json_encoded=json_encoded)