LoginSignup
0
0

More than 5 years have passed since last update.

【PHP】curlでproxyを通した場合、余分なヘッダーが付くときの対処法

Posted at

レスポンスのbodyを以下のようなコードで取得する場合

index.php
list($header, $body) = split("(\r\n){2}", $resp);

PROXYを通すとヘッダーに
HTTP/1.0 200 Connection established
がついてしまい、上手く取得できない。

  • 対処法

以下を追加する

index.php
if (false !== stripos($resp, "HTTP/1.0 200 Connection established\r\n\r\n")) {
$resp= str_ireplace("HTTP/1.0 200 Connection established\r\n\r\n", '',  $resp);
}
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0