I have an issue with utl_http which seems to not work as the documentation says. I think there is something I am doing wrong but after some researches, I can't find what I do in the bad way.
I would like to be able to read the cookie I receive in the response to my GET request. According to the Oracle Documentation of UTL_HTTP, I thought that a simple call to UTL_HTTP.GET_COOKIES would do what I want. But UTL_HTTP.GET_COOKIES, which return a table of cookies, is always empty whereas, in the header I receive in response to my request, there is effectiuvely a cookie (header Set-Cookie).
This is my PL/SQL code :
--API configuration UTL_HTTP.set_cookie_support( TRUE ); UTL_HTTP.clear_cookies(); UTL_HTTP.set_response_error_check(TRUE); --Start request m_Request := UTL_HTTP.begin_request( url => 'http://www2.leboncoin.fr/ai/form/3?ca=22_s', method => 'GET', http_version => 'HTTP/1.1' ); --Headers UTL_HTTP.set_header(m_Request, 'User-Agent', 'Chrome/43.0.2357.130'); --Execute the request m_Response := UTL_HTTP.GET_RESPONSE(m_Request); --Loop throught the headers FOR i IN 1..UTL_HTTP.GET_HEADER_COUNT(m_Response) LOOP UTL_HTTP.GET_HEADER(m_Response, i, v_Name, v_Value); --Display cookies of the response IF (UPPER(v_Name) = 'SET-COOKIE') THEN DBMS_OUTPUT.PUT_LINE(v_Name || ': ' || v_Value); END IF; END LOOP; --Nb of cookies UTL_HTTP.GET_COOKIES(v_Cookies); dbms_output.put_line('Nb of cookies : ' || v_Cookies.COUNT); --Close response UTL_HTTP.end_response(m_Response);
The result of the execution of this code is :
Set-Cookie: cookieFrame=1; expires=Mon, 27-Jun-2016 22:06:11 GMT; path=/; domain=.leboncoin.fr
Set-Cookie: s=red1xcbcd9d034c6855c0b67f96f396bf3d823922534c; path=/; domain=.leboncoin.fr
Nb of cookies : 0
Please, could you help me to find why ULT_HTTP says that there is no cookies in the result wheareas the ares 2 cookies in my example ?
Thank you very much for your help.