- gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_authenticate_filter: Application Data (%d bytes): %s", len, data);
-
- /* Base64 encode the data */
- enc_len = apr_base64_encode_len(len);
- if (NULL == (buf = apr_bucket_alloc(enc_len, c->bucket_alloc))) {
- gss_log(APLOG_MARK, APLOG_ERR, 0, r, "gssweb_authenticate_filter: Unable to allocate space for application data");
- apr_brigade_cleanup(brig_in);
- apr_brigade_cleanup(brig_out);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- enc_len = apr_base64_encode_binary(buf, data, len);
-
- /* Put the data in a bucket and add it to the the output brigade */
- bkt_out = apr_bucket_heap_create(buf, enc_len-1, apr_bucket_free, c->bucket_alloc);
- buf[enc_len] = '\0';
- gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_authenticate_filter: Sending (%d bytes):", enc_len, buf);
- APR_BRIGADE_INSERT_TAIL(brig_out, bkt_out);
-
- /* Send the output brigade */
- gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_authenticate_filter: Passing the application data brigade");
- if (OK != (ret = ap_pass_brigade(f->next, brig_out))) {
- apr_brigade_cleanup(brig_in);
- apr_brigade_cleanup(brig_out);
- return ret;
+
+ /* Base64 encode the data (if any) */
+ if (0 != len) {
+ enc_len = apr_base64_encode_len(len);
+ if (NULL == (buf = apr_bucket_alloc(enc_len, c->bucket_alloc))) {
+ gss_log(APLOG_MARK, APLOG_ERR, 0, r, "gssweb_authenticate_filter: Unable to allocate space for encoded application data");
+ apr_brigade_cleanup(brig_in);
+ apr_brigade_cleanup(brig_out);
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
+ enc_len = apr_base64_encode_binary(buf, data, len);
+
+ /* Put the data in a bucket and add it to the the output brigade */
+ bkt_out = apr_bucket_heap_create(buf, enc_len-1, apr_bucket_free, c->bucket_alloc);
+ buf[enc_len] = '\0';
+ gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_authenticate_filter: Sending (%d bytes)", enc_len);
+ APR_BRIGADE_INSERT_TAIL(brig_out, bkt_out);
+
+ /* Send the output brigade */
+ if (OK != (ret = ap_pass_brigade(f->next, brig_out))) {
+ apr_brigade_cleanup(brig_in);
+ apr_brigade_cleanup(brig_out);
+ return ret;
+ }