f00b4r / nusoap

:smirk: Fixed NuSOAP for PHP 5.6 - 8.2
https://f00b4r.github.io/nusoap/
320 stars 356 forks source link

How to send empty response from nusoap server #88

Closed jcav2 closed 2 years ago

jcav2 commented 2 years ago

Hi, i need to send only headers, and if everything goes well, need to send empty response, where Content-Length is 0

How can i do ?

Just now i am returning something like this:

HTTP/1.1 200 OK Date: Thu, 22 Sep 2022 15:55:02 GMT Server: Apache/2.4.54 (Ubuntu) X-SOAP-Server: NuSOAP/0.9.11 (1.123) Vary: Accept-Encoding Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/xml; charset=UTF-8

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body></SOAP-ENV:Body></SOAP-ENV:Envelope>

I need only return this:

HTTP/1.1 200 OK Date: Thu, 22 Sep 2022 15:55:02 GMT Server: Apache/2.4.54 (Ubuntu) X-SOAP-Server: NuSOAP/0.9.11 (1.123) Vary: Accept-Encoding Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/xml; charset=UTF-8

jcav2 commented 2 years ago

I solved this, changing line 4415 from:

$this->response = join("\r\n", $this->outgoing_headers) . "\r\n\r\n" . $payload;

to this:

if ($this->fault) { $this->response = join("\r\n", $this->outgoing_headers) . "\r\n\r\n" . $payload; } else { $this->response = join("\r\n", $this->outgoing_headers); }