CodeIgniter Forums
error 414 uri too long - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: error 414 uri too long (/showthread.php?tid=62403)



error 414 uri too long - Tecvid - 07-10-2015

hi guys, when i try to post long data without ci, via phpmyadmin for example, it works as it should, but if i try to post the same data via ci ( $this->input->post() ), i get 414 data, is this prevented by ci? how can i solve it?

p.s: i am posting with ajax, n i set the application/x-www-form-urlencoded header


RE: error 414 uri too long - mwhitney - 07-10-2015

Per the W3C definition of the 414 status code:
W3C Wrote:The server is refusing to service the request because the Request-URI is longer than the server is willing to interpret. This rare condition is only likely to occur when a client has improperly converted a POST request to a GET request with long query information, when the client has descended into a URI "black hole" of redirection (e.g., a redirected URI prefix that points to a suffix of itself), or when the server is under attack by a client attempting to exploit security holes present in some servers using fixed-length buffers for reading or manipulating the Request-URI.

Additionally, $this->input->post() is used to retrieve data which has been posted to the server, not to post data from a form.

You're probably going to have to show us some code to get any real help with this. Your description of the problem implies that you may have some problems with your view and controller as well as your JavaScript to handle the AJAX post.


RE: error 414 uri too long - Tecvid - 07-10-2015

this is my js code

Code:
var News = {
    edit: function (news, newsId) {
        var overlay   = getById('overlay'),
            editPopup = getById('editPopup');

        Ajax.request({
            url: '/az/management/get_news/' + newsId,
            success: function (azData) {
                Ajax.request({
                    url: '/ru/management/get_news/' + newsId,
                    success: function (ruData) {
                        window.frames[0].document.body.innerHTML = azData;
                        window.frames[1].document.body.innerHTML = ruData;

                        overlay.style.height    = document.compatMode != 'CSS1Compat' ?
                            document.body.scrollHeight :
                            document.documentElement.scrollHeight + 'px';
                        overlay.style.display   = 'block';
                        editPopup.style.display = 'block';
                    }
                });
            }
        });

        getById('update').onclick = function () {
            /* THE PRIMARY PROBLEM IS BELOW */
            Ajax.request({
                url: '/az/management/get_news/' + newsId +
                     '/?az=' + CKEDITOR.instances['az-editor'].getData() +
                     '/&ru=' + CKEDITOR.instances['ru-editor'].getData(),
                success: function (data) {
                    if (data) {
                        _endEditing();
                    }
                }
            });
        };

        getById('close').onclick = _endEditing;

        function _endEditing() {
            overlay.style.display   = '';
            editPopup.style.display = '';
        }
    },

    del: function () {
        //
    }
};

n this is my php code

PHP Code:
public function update_news($news_id)
    {
        
$this->db->where('news_id'$news_id);
        
$this->db->set('news_text'$this->input->post('az'));
        
$az $this->db->update('az_news');

        
$this->db->where('news_id'$news_id);
        
$this->db->set('news_text'$this->input->post('ru'));
        
$ru $this->db->update('ru_news');

        if (
$az === FALSE || $ru === FALSE)
        {
            exit;
        }

        exit(
TRUE);
    } 

that's all, no view files


RE: error 414 uri too long - Tecvid - 07-11-2015

i am really stupid :/ i try to send post data but i do it via query instead of passage data: 'query=blabla" :/ n even my Ajax.request() function works with post data by default if no method is set, finally i have realized my mistake, sorry for disturbing