Skip to content

Commit 291197d

Browse files
author
Avatarsia
committed
fix(woocommerce): expose response headers from inline WC client
Adds getHeaders() / getHeader() accessors to the inline WCResponse class and captures HTTP response headers case-insensitively via CURLOPT_HEADERFUNCTION. Required foundation for pagination handling (Issue OpenXE-org#262).
1 parent 8bb1397 commit 291197d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

www/pages/shopimporter_woocommerce.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,13 +1245,26 @@ public function getCode()
12451245
/**
12461246
* Get headers.
12471247
*
1248-
* @return array $headers WCResponse headers.
1248+
* @return array $headers WCResponse headers (keys normalized to lowercase).
12491249
*/
12501250
public function getHeaders()
12511251
{
12521252
return $this->headers;
12531253
}
12541254

1255+
/**
1256+
* Get a single response header by name (case-insensitive).
1257+
*
1258+
* @param string $name Header name (e.g. 'x-wp-totalpages').
1259+
*
1260+
* @return string|null Header value or null if not present.
1261+
*/
1262+
public function getHeader($name)
1263+
{
1264+
$key = strtolower($name);
1265+
return isset($this->headers[$key]) ? $this->headers[$key] : null;
1266+
}
1267+
12551268
/**
12561269
* Get body.
12571270
*
@@ -2137,6 +2150,7 @@ protected function getResponseHeaders()
21372150

21382151
list($key, $value) = explode(': ', $line);
21392152

2153+
$key = strtolower($key);
21402154
$headers[$key] = isset($headers[$key]) ? $headers[$key] . ', ' . trim($value) : trim($value);
21412155
}
21422156

0 commit comments

Comments
 (0)