httpios geturl does not send header for POST

Version 1
    This document was generated from CDN thread

    Created by: Tomas Ussher on 19-01-2011 12:48:54 PM
    I had noticed this problem already long time ago but I was hoping it would get fixed in subsequent releases.
    However it still exists in 15.0(1)M4. It causes a serious issue, preventing us from completing an application (We are Cisco Registered Developer).
     
    The problem is that when -query is used with 'httpios geturl', custom headers are NOT sent to the server. This prevents from using POST and Authorization, that is indispensable for our application to work. I have not found any evidence indicating that one can not set custom headers in TCL http POST.
     
    Test code:
    proc act_Setup {} {
     set query {Test Body}
     set hdr {Authorization {Basic uuuuu:pppp} Custom XXX}
     set url http://10.0.1.128:8000/post.cgi
     ::httpios::geturl $url -headers $hdr -command httpCallback -query $query
    }
    proc httpCallback {token} {
     puts -nonewline "Status: [::httpios::status $token]"
     ::httpios::cleanup $token
     call close
    }
    package require httpios 1.0
    set fsm(INIT,ev_handoff) "act_Setup same_state"
    fsm define fsm INIT
     
    Debug output:
    Jan 19 18:36:39.704 CET: //4256//PACK:/tcl_httpiosGeturlObjCmd:  ::httpios::geturl http://10.0.1.128:8000/post.cgi -headers Authorization {Basic uuuuu:pppp} Custom XXX -command httpCallback -query Test Body
    Jan 19 18:36:39.708 CET: //4256//PACK:/tcl_httpiosGeturlObjCmd: Current NS: ::
    Jan 19 18:36:39.708 CET: //4256//PACK:/tcl_httpiosGeturlObjCmd: URL: http://10.0.1.128:8000/post.cgi
    Jan 19 18:36:39.708 CET: //-1//PACK:/httpios_get_custom_headers: No Of Headers: 4
    Jan 19 18:36:39.708 CET: //-1//PACK:/httpios_get_custom_headers: Authorization: Basic uuuuu:pppp
    Custom: XXX

    Received by server:
    POST /post.cgi HTTP/1.1
    Host: 10.0.1.128:8000
    Content-Length: 9
    Content-Type: application/x-www-form-urlencoded
    Connection: close
    Accept: text/vxml, text/x-vxml, application/vxml, application/x-vxml, application/voicexml, application/x-voicexml, text/plain, text/html, audio/basic, audio/wav, multipart/form-data, application/octet-stream
    User-Agent: Cisco-IOS-C2801/15.0
     
    Test Body
     
    Again, when using GET operation, there is no problem and custom header are correctly sent, allowing authorization to work.

     

    Subject: RE: httpios geturl does not send header for POST
    Replied by: JAMES DEPHILLIP II on 28-08-2012 07:39:40 PM
    I noticed this same issue on a VG over a year ago however I only noticed it while doing a HTTP POST. Is this still an issue or has this been resolved?
     
    I had noticed this problem already long time ago but I was hoping it would get fixed in subsequent releases.
    However it still exists in 15.0(1)M4. It causes a serious issue, preventing us from completing an application (We are Cisco Registered Developer).
     
    The problem is that when -query is used with 'httpios geturl', custom headers are NOT sent to the server. This prevents from using POST and Authorization, that is indispensable for our application to work. I have not found any evidence indicating that one can not set custom headers in TCL http POST.
     
    Test code:
    proc act_Setup {} {
     set query {Test Body}
     set hdr {Authorization {Basic uuuuu:pppp} Custom XXX}
     set url http://10.0.1.128:8000/post.cgi
     ::httpios::geturl $url -headers $hdr -command httpCallback -query $query
    }
    proc httpCallback {token} {
     puts -nonewline "Status: [::httpios::status $token]"
     ::httpios::cleanup $token
     call close
    }
    package require httpios 1.0
    set fsm(INIT,ev_handoff) "act_Setup same_state"
    fsm define fsm INIT
     
    Debug output:
    Jan 19 18:36:39.704 CET: //4256//PACK:/tcl_httpiosGeturlObjCmd:  ::httpios::geturl http://10.0.1.128:8000/post.cgi -headers Authorization {Basic uuuuu:pppp} Custom XXX -command httpCallback -query Test Body
    Jan 19 18:36:39.708 CET: //4256//PACK:/tcl_httpiosGeturlObjCmd: Current NS: ::
    Jan 19 18:36:39.708 CET: //4256//PACK:/tcl_httpiosGeturlObjCmd: URL: http://10.0.1.128:8000/post.cgi
    Jan 19 18:36:39.708 CET: //-1//PACK:/httpios_get_custom_headers: No Of Headers: 4
    Jan 19 18:36:39.708 CET: //-1//PACK:/httpios_get_custom_headers: Authorization: Basic uuuuu:pppp
    Custom: XXX

    Received by server:
    POST /post.cgi HTTP/1.1
    Host: 10.0.1.128:8000
    Content-Length: 9
    Content-Type: application/x-www-form-urlencoded
    Connection: close
    Accept: text/vxml, text/x-vxml, application/vxml, application/x-vxml, application/voicexml, application/x-voicexml, text/plain, text/html, audio/basic, audio/wav, multipart/form-data, application/octet-stream
    User-Agent: Cisco-IOS-C2801/15.0
     
    Test Body
     
    Again, when using GET operation, there is no problem and custom header are correctly sent, allowing authorization to work.

     


    Subject: RE: httpios geturl does not send header for POST
    Replied by: Tomas Ussher on 29-08-2012 12:31:13 PM
    if you don't use -query with 'httpios geturl', will you able to send customer headers.



     
    Excuse me, and how one would be supposed to do POST without using -query ?
     
    From http TCL manual:
    This flag causes ::http::geturl to do a POST request that passes the query to the server. The query must be an x-url-encoding formatted query. The::http::formatQuery procedure can be used to do the formatting.

    Again, the question is:
     
    Using POST method with httpio AND Basic authentication appears not to be possible

    Subject: RE: httpios geturl does not send header for POST
    Replied by: Raghavendra Gutty Veeranagappa on 29-08-2012 08:49:45 AM
    Hi,

    if you don't use -query with 'httpios geturl', will you able to send customer headers.

    Thanks,
    Raghavendra