Edit report at http://bugs.php.net/bug.php?id=54898&edit=1

 ID:                 54898
 Updated by:         bj...@php.net
 Reported by:        simast at gmail dot com
 Summary:            HTTP context option "ignore_errors" does not work as
                     expected
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Streams related
 Operating System:   Linux/Ubuntu
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

You are doing something wrong.



/errors.php:

<?php

$errorcode = $_GET["errorcode"];

header("HTTP/1.0 $errorcode foobar");



echo "This is the content of $errorcode";

?>



And executing:



<?php

$opts = array(

    "ignore_errors" => 1,

);



$context  = stream_context_create(array("http" => $opts));

foreach(range(200, 404) as $errorcode) {

    $content = file_get_contents("http://localhost/errors.php?

errorcode=$errorcode", false, $context);

    echo $http_response_header[0], " - ", $content, "\n";

}

?>



Gives me:



HTTP/1.0 200 foobar - This is the content of 200

HTTP/1.0 201 foobar - This is the content of 201

HTTP/1.0 202 foobar - This is the content of 202

HTTP/1.0 203 foobar - This is the content of 203

HTTP/1.0 204 foobar - This is the content of 204

HTTP/1.0 205 foobar - This is the content of 205

HTTP/1.0 206 foobar - This is the content of 206

HTTP/1.0 207 foobar - This is the content of 207

HTTP/1.0 208 foobar - This is the content of 208

HTTP/1.0 209 foobar - This is the content of 209

HTTP/1.0 210 foobar - This is the content of 210

HTTP/1.0 211 foobar - This is the content of 211

HTTP/1.0 212 foobar - This is the content of 212

HTTP/1.0 213 foobar - This is the content of 213

HTTP/1.0 214 foobar - This is the content of 214

HTTP/1.0 215 foobar - This is the content of 215

HTTP/1.0 216 foobar - This is the content of 216

HTTP/1.0 217 foobar - This is the content of 217

HTTP/1.0 218 foobar - This is the content of 218

HTTP/1.0 219 foobar - This is the content of 219

HTTP/1.0 220 foobar - This is the content of 220

HTTP/1.0 221 foobar - This is the content of 221

HTTP/1.0 222 foobar - This is the content of 222

HTTP/1.0 223 foobar - This is the content of 223

HTTP/1.0 224 foobar - This is the content of 224

HTTP/1.0 225 foobar - This is the content of 225

HTTP/1.0 226 foobar - This is the content of 226

HTTP/1.0 227 foobar - This is the content of 227

HTTP/1.0 228 foobar - This is the content of 228

HTTP/1.0 229 foobar - This is the content of 229

HTTP/1.0 230 foobar - This is the content of 230

HTTP/1.0 231 foobar - This is the content of 231

HTTP/1.0 232 foobar - This is the content of 232

HTTP/1.0 233 foobar - This is the content of 233

HTTP/1.0 234 foobar - This is the content of 234

HTTP/1.0 235 foobar - This is the content of 235

HTTP/1.0 236 foobar - This is the content of 236

HTTP/1.0 237 foobar - This is the content of 237

HTTP/1.0 238 foobar - This is the content of 238

HTTP/1.0 239 foobar - This is the content of 239

HTTP/1.0 240 foobar - This is the content of 240

HTTP/1.0 241 foobar - This is the content of 241

HTTP/1.0 242 foobar - This is the content of 242

HTTP/1.0 243 foobar - This is the content of 243

HTTP/1.0 244 foobar - This is the content of 244

HTTP/1.0 245 foobar - This is the content of 245

HTTP/1.0 246 foobar - This is the content of 246

HTTP/1.0 247 foobar - This is the content of 247

HTTP/1.0 248 foobar - This is the content of 248

HTTP/1.0 249 foobar - This is the content of 249

HTTP/1.0 250 foobar - This is the content of 250

HTTP/1.0 251 foobar - This is the content of 251

HTTP/1.0 252 foobar - This is the content of 252

HTTP/1.0 253 foobar - This is the content of 253

HTTP/1.0 254 foobar - This is the content of 254

HTTP/1.0 255 foobar - This is the content of 255

HTTP/1.0 256 foobar - This is the content of 256

HTTP/1.0 257 foobar - This is the content of 257

HTTP/1.0 258 foobar - This is the content of 258

HTTP/1.0 259 foobar - This is the content of 259

HTTP/1.0 260 foobar - This is the content of 260

HTTP/1.0 261 foobar - This is the content of 261

HTTP/1.0 262 foobar - This is the content of 262

HTTP/1.0 263 foobar - This is the content of 263

HTTP/1.0 264 foobar - This is the content of 264

HTTP/1.0 265 foobar - This is the content of 265

HTTP/1.0 266 foobar - This is the content of 266

HTTP/1.0 267 foobar - This is the content of 267

HTTP/1.0 268 foobar - This is the content of 268

HTTP/1.0 269 foobar - This is the content of 269

HTTP/1.0 270 foobar - This is the content of 270

HTTP/1.0 271 foobar - This is the content of 271

HTTP/1.0 272 foobar - This is the content of 272

HTTP/1.0 273 foobar - This is the content of 273

HTTP/1.0 274 foobar - This is the content of 274

HTTP/1.0 275 foobar - This is the content of 275

HTTP/1.0 276 foobar - This is the content of 276

HTTP/1.0 277 foobar - This is the content of 277

HTTP/1.0 278 foobar - This is the content of 278

HTTP/1.0 279 foobar - This is the content of 279

HTTP/1.0 280 foobar - This is the content of 280

HTTP/1.0 281 foobar - This is the content of 281

HTTP/1.0 282 foobar - This is the content of 282

HTTP/1.0 283 foobar - This is the content of 283

HTTP/1.0 284 foobar - This is the content of 284

HTTP/1.0 285 foobar - This is the content of 285

HTTP/1.0 286 foobar - This is the content of 286

HTTP/1.0 287 foobar - This is the content of 287

HTTP/1.0 288 foobar - This is the content of 288

HTTP/1.0 289 foobar - This is the content of 289

HTTP/1.0 290 foobar - This is the content of 290

HTTP/1.0 291 foobar - This is the content of 291

HTTP/1.0 292 foobar - This is the content of 292

HTTP/1.0 293 foobar - This is the content of 293

HTTP/1.0 294 foobar - This is the content of 294

HTTP/1.0 295 foobar - This is the content of 295

HTTP/1.0 296 foobar - This is the content of 296

HTTP/1.0 297 foobar - This is the content of 297

HTTP/1.0 298 foobar - This is the content of 298

HTTP/1.0 299 foobar - This is the content of 299

HTTP/1.0 300 foobar - This is the content of 300

HTTP/1.0 301 foobar - This is the content of 301

HTTP/1.0 302 foobar - This is the content of 302

HTTP/1.0 303 foobar - This is the content of 303

HTTP/1.0 304 foobar - This is the content of 304

HTTP/1.0 305 foobar - This is the content of 305

HTTP/1.0 306 foobar - This is the content of 306

HTTP/1.0 307 foobar - This is the content of 307

HTTP/1.0 308 foobar - This is the content of 308

HTTP/1.0 309 foobar - This is the content of 309

HTTP/1.0 310 foobar - This is the content of 310

HTTP/1.0 311 foobar - This is the content of 311

HTTP/1.0 312 foobar - This is the content of 312

HTTP/1.0 313 foobar - This is the content of 313

HTTP/1.0 314 foobar - This is the content of 314

HTTP/1.0 315 foobar - This is the content of 315

HTTP/1.0 316 foobar - This is the content of 316

HTTP/1.0 317 foobar - This is the content of 317

HTTP/1.0 318 foobar - This is the content of 318

HTTP/1.0 319 foobar - This is the content of 319

HTTP/1.0 320 foobar - This is the content of 320

HTTP/1.0 321 foobar - This is the content of 321

HTTP/1.0 322 foobar - This is the content of 322

HTTP/1.0 323 foobar - This is the content of 323

HTTP/1.0 324 foobar - This is the content of 324

HTTP/1.0 325 foobar - This is the content of 325

HTTP/1.0 326 foobar - This is the content of 326

HTTP/1.0 327 foobar - This is the content of 327

HTTP/1.0 328 foobar - This is the content of 328

HTTP/1.0 329 foobar - This is the content of 329

HTTP/1.0 330 foobar - This is the content of 330

HTTP/1.0 331 foobar - This is the content of 331

HTTP/1.0 332 foobar - This is the content of 332

HTTP/1.0 333 foobar - This is the content of 333

HTTP/1.0 334 foobar - This is the content of 334

HTTP/1.0 335 foobar - This is the content of 335

HTTP/1.0 336 foobar - This is the content of 336

HTTP/1.0 337 foobar - This is the content of 337

HTTP/1.0 338 foobar - This is the content of 338

HTTP/1.0 339 foobar - This is the content of 339

HTTP/1.0 340 foobar - This is the content of 340

HTTP/1.0 341 foobar - This is the content of 341

HTTP/1.0 342 foobar - This is the content of 342

HTTP/1.0 343 foobar - This is the content of 343

HTTP/1.0 344 foobar - This is the content of 344

HTTP/1.0 345 foobar - This is the content of 345

HTTP/1.0 346 foobar - This is the content of 346

HTTP/1.0 347 foobar - This is the content of 347

HTTP/1.0 348 foobar - This is the content of 348

HTTP/1.0 349 foobar - This is the content of 349

HTTP/1.0 350 foobar - This is the content of 350

HTTP/1.0 351 foobar - This is the content of 351

HTTP/1.0 352 foobar - This is the content of 352

HTTP/1.0 353 foobar - This is the content of 353

HTTP/1.0 354 foobar - This is the content of 354

HTTP/1.0 355 foobar - This is the content of 355

HTTP/1.0 356 foobar - This is the content of 356

HTTP/1.0 357 foobar - This is the content of 357

HTTP/1.0 358 foobar - This is the content of 358

HTTP/1.0 359 foobar - This is the content of 359

HTTP/1.0 360 foobar - This is the content of 360

HTTP/1.0 361 foobar - This is the content of 361

HTTP/1.0 362 foobar - This is the content of 362

HTTP/1.0 363 foobar - This is the content of 363

HTTP/1.0 364 foobar - This is the content of 364

HTTP/1.0 365 foobar - This is the content of 365

HTTP/1.0 366 foobar - This is the content of 366

HTTP/1.0 367 foobar - This is the content of 367

HTTP/1.0 368 foobar - This is the content of 368

HTTP/1.0 369 foobar - This is the content of 369

HTTP/1.0 370 foobar - This is the content of 370

HTTP/1.0 371 foobar - This is the content of 371

HTTP/1.0 372 foobar - This is the content of 372

HTTP/1.0 373 foobar - This is the content of 373

HTTP/1.0 374 foobar - This is the content of 374

HTTP/1.0 375 foobar - This is the content of 375

HTTP/1.0 376 foobar - This is the content of 376

HTTP/1.0 377 foobar - This is the content of 377

HTTP/1.0 378 foobar - This is the content of 378

HTTP/1.0 379 foobar - This is the content of 379

HTTP/1.0 380 foobar - This is the content of 380

HTTP/1.0 381 foobar - This is the content of 381

HTTP/1.0 382 foobar - This is the content of 382

HTTP/1.0 383 foobar - This is the content of 383

HTTP/1.0 384 foobar - This is the content of 384

HTTP/1.0 385 foobar - This is the content of 385

HTTP/1.0 386 foobar - This is the content of 386

HTTP/1.0 387 foobar - This is the content of 387

HTTP/1.0 388 foobar - This is the content of 388

HTTP/1.0 389 foobar - This is the content of 389

HTTP/1.0 390 foobar - This is the content of 390

HTTP/1.0 391 foobar - This is the content of 391

HTTP/1.0 392 foobar - This is the content of 392

HTTP/1.0 393 foobar - This is the content of 393

HTTP/1.0 394 foobar - This is the content of 394

HTTP/1.0 395 foobar - This is the content of 395

HTTP/1.0 396 foobar - This is the content of 396

HTTP/1.0 397 foobar - This is the content of 397

HTTP/1.0 398 foobar - This is the content of 398

HTTP/1.0 399 foobar - This is the content of 399

HTTP/1.0 400 foobar - This is the content of 400

HTTP/1.0 401 foobar - This is the content of 401

HTTP/1.0 402 foobar - This is the content of 402

HTTP/1.0 403 foobar - This is the content of 403

HTTP/1.0 404 foobar - This is the content of 404


Previous Comments:
------------------------------------------------------------------------
[2011-05-21 17:16:51] simast at gmail dot com

Description:
------------
>From documentation I would assume that making a HTTP request with 

"ignore_errors" context option I should always get response body no
matter the 

HTTP response code server sent back. This seems to work for just some of
the 

response codes (like 404) and will fail with others - "400 Bad Request"
for 

example.



This affects fopen() and file_get_contents() as far as I have tested.



An ideal solution would be to:



- if fopen() is called with HTTP context and "ignore_errors" - return a
valid 

resource (currently it will return false with a E_WARNING). Next calling


stream_get_contents() on this resource should return response body. If 

"ignore_errors" is not set - behave the old way - keeping backwards-

compatibility.



- if file_get_contents() is called with HTTP context and "ignore_errors"
- 

return response body no matter HTTP response code. Otherwise - keep old


functionality for backwards compatibility.



Because of this bug writing an API client with HTTP streams is somewhat
of  

challenge (or not possible at all).



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=54898&edit=1

Reply via email to