FUNCTION z_http_url.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     REFERENCE(IV_URL) TYPE  CSEQUENCE
*"  EXPORTING
*"     REFERENCE(EV_RESPONSE) TYPE  CSEQUENCE
*"     REFERENCE(EO_RESPONSE) TYPE REF TO  IF_HTTP_RESPONSE
*"     REFERENCE(EV_CODE) TYPE  SYSUBRC
*"     REFERENCE(EV_MESSAGE) TYPE  STRING
*"----------------------------------------------------------------------
* URL 을 입력 받아서 http 통신하고 응답 받은 내용은 string 으로 반환한다.

  DATAlo_client TYPE REF TO if_http_client,
        lv_url TYPE string.

  CHECKiv_url IS NOT INITIAL.
  lv_url iv_url.
  FIND REGEX '^https?://' IN lv_url IGNORING CASE.
  IF sy-subrc <> 0.
    CONCATENATE 'http://' lv_url INTO lv_url.
  ENDIF.

  cl_http_client=>create_by_url(
    EXPORTING
      url                lv_url
    IMPORTING
      client             lo_client
    EXCEPTIONS
      argument_not_found 1
      plugin_not_active  2
      internal_error     3
      OTHERS             4
  ).
  CHECKsy-subrc EQ 0.

  lo_client->send(
    EXCEPTIONS
      http_communication_failure 1
      http_invalid_state         2
      http_processing_failed     3
      http_invalid_timeout       4
      OTHERS                     5
  ).
*  CHECK: sy-subrc EQ 0.
  IF sy-subrc <> 0.
    lo_client->get_last_error(
      IMPORTING
        code ev_code
        message ev_message
    ).
  ENDIF.

  lo_client->receive(
    EXCEPTIONS
      http_communication_failure 1
      http_invalid_state         2
      http_processing_failed     3
      OTHERS                     4
  ).
*  CHECK: sy-subrc EQ 0.
  IF sy-subrc <> 0.
    lo_client->get_last_error(
      IMPORTING
        code ev_code
        message ev_message
    ).
  ENDIF.

  IF lo_client->response IS NOT INITIAL.
    eo_response lo_client->response.
    ev_response lo_client->response->get_cdata).
  ENDIF.



ENDFUNCTION.