1

We are using the drupal_http_request function to send some data to salesforce. We've been told that one of the fields is being cut off and that they are receiving incomplete data. When I examine the response object (via a debugger), I'm seeing all the data that was sent out. Am I correct in my assumption that none of the data is being truncated on the Drupal side of things?

  //I see all the data here that was sent out.
  list($response, $result->data) = preg_split("/\r\n\r\n|\n\n|\r\r/", $response, 2);
  $response = preg_split("/\r\n|\n|\r/", $response);

We are using the Rules HTTP Client. The request object data is being set in a rule:

orgid=00ZZ00000zzzzz
retURL=http://example.com
recordType=012U00000001eYn
Sender_IP__c=[entityform:field_salesforce_context]
email=[entityform:field-email]
name=[entityform:field-contact-form-first-name] [entityform:field-contact-form-last-name]
description=[entityform:field_please_provide_as_much_det]
00NU000000zzzzzz=[entityform:field_category]
external=1

The actual code that calles drupal_http_request is this:

 $data = str_replace("\r\n", '&', $data);
 $data = explode('&', $data);
 foreach ($data as &$item) {
    list($name, $value) = explode('=', $item, 2);
    $value = urlencode($value);
    $item = "{$name}={$value}";
 }
 $options['data'] = implode('&', $data);

 // Max redirects.
 $options['max_redirects'] = empty($max_redirects) ? 3 : $max_redirects;

 // Timeout.
 $options['timeout'] = empty($timeout) ? 30 : $timeout;

 // HERE
 $response = drupal_http_request($url, $options);
 if (isset($response->error)) {
    return;
 }
 else {
    return array('http_response' => $response->data);
 }

When I set a breakpoint here and step through the code all the data is present. The response object looks good:

data: " http://example.com"> if (this.SfdcApp && this.SfdcApp.projectOneNavigator) { SfdcApp.projectOneNavigator.handleRedirect('someURL'); } else if (window.location.replace){ window.location.replace('someURL');} else {;window.location.href ='someURL';} � �"

code: 200

protocol: "HTTP/1.1"

status: "OK"

request:

"POST /servlet/servlet.WebToCase?encoding=UTF-8 HTTP/1.0 Content-Type: application/x-www-form-urlencoded User-Agent: Drupal (+http://drupal.org/) Host: gsa-peo.my.salesforce.com Content-Length: 1536 orgid=00ZZ00000zzzzz&retURL=http%3A%2F%example.com&recordType=012U00000001eYn&Sender_IP__c=127.0.0.1&email=bsmith%40example.com&name=Bob+Smith&description=Sed+ligula+ipsum%2C+scelerisque+vel+fermentum+id%2C+aliquam+ac+risus.+Ut+sed+euismod+lectus%2C+non+congue+massa.+Nam+est+nisi%3B+laoreet+in+vulputate+eget%2C+porta+nec+eros%21+Nulla+non+aliquam+leo%2C+et+ornare+ligula.+Morbi+egestas+augue+a+purus+suscipit+placerat.+Proin+cursus+iaculis+risus%2C+id+ultricies+nullam.&Sed ligula ipsum, scelerisque vel fermentum id, aliquam ac risus. Ut sed euismod lectus, non congue massa. Nam est nisi; laoreet in vulputate eget, porta nec eros! Nulla non aliquam leo, et ornare ligula. Morbi egestas augue a purus suscipit placerat. Proin cursus iaculis risus, id ultricies nullam.=&=&Sed ligula ipsum, scelerisque vel fermentum id, aliquam ac risus. Ut sed euismod lectus, non congue massa. Nam est nisi; laoreet in vulputate eget, porta nec eros! Nulla non aliquam leo, et ornare ligula. Morbi egestas augue a purus suscipit placerat. Proin cursus iaculis risus, id ultricies nullam.=&=&Sed ligula ipsum, scelerisque vel fermentum id, aliquam ac risus. Ut sed euismod lectus, non congue massa. Nam est nisi; laoreet in vulputate eget, porta nec eros! Nulla non aliquam leo, et ornare ligula. Morbi egestas augue a purus suscipit placerat. Proin cursus iaculis risus, id ultricies nullam.&00NU0000004z903=General+information&external=1"

url: "slaesforce URL"

1
  • 1
    The function itself should not change the data, and I think there's something wrong in the way it's called. If you can show how you make the call (with sensitive data replaced), others will be able to point out any problems.
    – AKS
    Commented Jun 23, 2015 at 21:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.