Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Licensed to Jasig under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Jasig licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

Author: Adam Franco <afranco@middlebury.edu>
License: http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
File Size: 152 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

CAS_ProxiedService_Http_Post:: (3 methods):
  setContentType()
  setBody()
  populateRequest()


Class: CAS_ProxiedService_Http_Post  - X-Ref

This class is used to make proxied service requests via the HTTP POST method.

Usage Example:

try {
$service = phpCAS::getProxiedService(PHPCAS_PROXIED_SERVICE_HTTP_POST);
$service->setUrl('http://www.example.com/path/');
$service->setContentType('text/xml');
$service->setBody('<?xml version="1.0"?'.'><methodCall><methodName>example.search</methodName></methodCall>');
$service->send();
if ($service->getResponseStatusCode() == 200)
return $service->getResponseBody();
else
// The service responded with an error code 404, 500, etc.
throw new Exception('The service responded with an error.');

} catch (CAS_ProxyTicketException $e) {
if ($e->getCode() == PHPCAS_SERVICE_PT_FAILURE)
return "Your login has timed out. You need to log in again.";
else
// Other proxy ticket errors are from bad request format
// (shouldn't happen) or CAS server failure (unlikely) so lets just
// stop if we hit those.
throw $e;
} catch (CAS_ProxiedService_Exception $e) {
// Something prevented the service request from being sent or received.
// We didn't even get a valid error response (404, 500, etc), so this
// might be caused by a network error or a DNS resolution failure.
// We could handle it in some way, but for now we will just stop.
throw $e;
}

setContentType($contentType)   X-Ref
Set the content type of this POST request.

param: string $contentType content type
return: void

setBody($body)   X-Ref
Set the body of this POST request.

param: string $body body to set
return: void

populateRequest(CAS_Request_RequestInterface $request)   X-Ref
Add any other parts of the request needed by concrete classes

param: CAS_Request_RequestInterface $request request interface class
return: void