Skip to Content
Jul 12, 2019 at 02:48 PM

cl_http_client can't set header with linebreak

647 Views Last edit Jul 12, 2019 at 02:51 PM 2 rev

I have to send a http request with a header, which contains a linebreak (<CR><LF> to be specific). (This is allowed, see )

If I create a string (iv_mystring_with_cr_lf) and include a `cl_abap_char_utilities=>cr_lf` and pass that string as value to `lo_http_client->request->set_header_field( name = 'HeaderName' value = iv_mystring_with_cr_lf ).`, I receive an http_communication_failure error wenn calling lr_http_client->send( ). If I remove the cr_lf chars, everything works, except that my header is wrong...

Did I miss something? Are there any workarounds? Unfortunately I have to send the header with <CR><LF>.

Here is a minimal example which dumps.

         lo_http_client type ref to if_http_client,
         lv_somestring type string,
         lv_url type string.

  lv_url = ''.

        url                = lv_url
        ssl_id             = 'DFAULT'
        client = lo_http_client ).

  lv_somestring = 'test'.
  CONCATENATE lv_somestring cl_abap_char_utilities=>cr_lf lv_somestring into lv_somestring.

  lo_http_client->request->set_header_field( name = 'someHeader' value = lv_somestring ).

  lo_http_client->send( ). "crash.