Skip to content

Commit b88630e

Browse files
committed
new version of http_parse_headers that doesnt use deprecated code
1 parent e731642 commit b88630e

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

tavernaSender.php

+26-12
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function set_ssl_status() {
8585
* Set verify ssl in case you are using an unsigned cert.
8686
*/
8787
function set_ssl() {
88-
$this->curl_connect->sslVersion = 3;
88+
// let tuque figure it out $this->curl_connect->sslVersion = 3;
8989
$this->curl_connect->verifyHost = $this->ssl_status;
9090
$this->curl_connect->verifyPeer = $this->ssl_status;
9191
}
@@ -116,27 +116,41 @@ function send_Message($message) {
116116
/**
117117
* replacement for pecl parse headers
118118
* taken from php.net
119-
* @param string $header
119+
* @param string $raw_headers
120120
* @return array
121121
*/
122-
function http_parse_headers($header) {
123-
$retVal = array();
124-
$fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $header));
125-
foreach ($fields as $field) {
126-
if (preg_match('/([^:]+): (.+)/m', $field, $match)) {
127-
$match[1] = preg_replace('/(?<=^|[\x09\x20\x2D])./e', 'strtoupper("\0")', strtolower(trim($match[1])));
128-
if (isset($retVal[$match[1]])) {
129-
$retVal[$match[1]] = array($retVal[$match[1]], $match[2]);
122+
function http_parse_headers($raw_headers) {
123+
$headers = array();
124+
$key = '';
125+
126+
foreach(explode("\n", $raw_headers) as $i => $h) {
127+
$h = explode(':', $h, 2);
128+
129+
if (isset($h[1])) {
130+
if (!isset($headers[$h[0]]))
131+
$headers[$h[0]] = trim($h[1]);
132+
elseif (is_array($headers[$h[0]])) {
133+
$headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));
130134
}
131135
else {
132-
$retVal[$match[1]] = trim($match[2]);
136+
$headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));
133137
}
138+
139+
$key = $h[0];
140+
}
141+
else {
142+
if (substr($h[0], 0, 1) == "\t")
143+
$headers[$key] .= "\r\n\t".trim($h[0]);
144+
elseif (!$key)
145+
$headers[0] = trim($h[0]);
134146
}
135147
}
136-
return $retVal;
148+
149+
return $headers;
137150
}
138151

139152

153+
140154
/**
141155
* This function is to parse uuid from the feedback message.
142156
* There must have full url of the t2flow on taverna server.

0 commit comments

Comments
 (0)