|
295 | 295 | //Проверка, что вставка произведена успешно
|
296 | 296 | if ($status->success() == true) {
|
297 | 297 |
|
| 298 | + // Изменение HTML статуса |
| 299 | + $response->setStatusCode(201, "Created"); |
| 300 | +
|
298 | 301 | $robot->id = $status->getModel()->id;
|
299 | 302 |
|
300 | 303 | $response->setJsonContent(array('status' => 'OK', 'data' => $robot));
|
301 | 304 |
|
302 | 305 | } else {
|
303 | 306 |
|
304 | 307 | // Изменение HTML статуса
|
305 |
| - $response->setStatusCode(500, "Internal Error"); |
| 308 | + $response->setStatusCode(409, "Conflict"); |
306 | 309 |
|
307 | 310 | //Отправляем сообщение об ошибке клиенту
|
308 | 311 | $errors = array();
|
|
346 | 349 | } else {
|
347 | 350 |
|
348 | 351 | //Изменение HTML статуса
|
349 |
| - $response->setStatusCode(500, "Internal Error"); |
| 352 | + $response->setStatusCode(409, "Conflict"); |
350 | 353 |
|
351 | 354 | $errors = array();
|
352 | 355 | foreach ($status->getMessages() as $message) {
|
|
383 | 386 | } else {
|
384 | 387 |
|
385 | 388 | // Изменение HTTP статуса
|
386 |
| - $response->setStatusCode(500, "Internal Error"); |
| 389 | + $response->setStatusCode(409, "Conflict"); |
387 | 390 |
|
388 | 391 | $errors = array();
|
389 | 392 | foreach ($status->getMessages() as $message) {
|
|
450 | 453 | curl -i -X POST -d '{"name":"C-3PO","type":"droid","year":1977}'
|
451 | 454 | http://localhost/my-rest-api/api/robots
|
452 | 455 |
|
453 |
| - HTTP/1.1 200 OK |
| 456 | + HTTP/1.1 201 Created |
454 | 457 | Date: Wed, 12 Sep 2012 07:15:09 GMT
|
455 | 458 | Server: Apache/2.2.22 (Unix) DAV/2
|
456 | 459 | Content-Length: 75
|
|
465 | 468 | curl -i -X POST -d '{"name":"C-3PO","type":"droid","year":1977}'
|
466 | 469 | http://localhost/my-rest-api/api/robots
|
467 | 470 |
|
468 |
| - HTTP/1.1 500 Internal Error |
| 471 | + HTTP/1.1 409 Conflict |
469 | 472 | Date: Wed, 12 Sep 2012 07:18:28 GMT
|
470 | 473 | Server: Apache/2.2.22 (Unix) DAV/2
|
471 | 474 | Content-Length: 63
|
|
480 | 483 | curl -i -X PUT -d '{"name":"ASIMO","type":"humanoid","year":2000}'
|
481 | 484 | http://localhost/my-rest-api/api/robots/4
|
482 | 485 |
|
483 |
| - HTTP/1.1 500 Internal Error |
| 486 | + HTTP/1.1 409 Conflict |
484 | 487 | Date: Wed, 12 Sep 2012 08:48:01 GMT
|
485 | 488 | Server: Apache/2.2.22 (Unix) DAV/2
|
486 | 489 | Content-Length: 104
|
|
0 commit comments