| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Redistribution and use in source and binary forms, with or without | 
					
						
							|  |  |  |  * modification, are permitted provided that the following conditions are met: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 1. Redistributions of source code must retain the above copyright notice, this | 
					
						
							|  |  |  |  *    list of conditions and the following disclaimer. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 2. Redistributions in binary form must reproduce the above copyright notice, | 
					
						
							|  |  |  |  *    this list of conditions and the following disclaimer in the documentation | 
					
						
							|  |  |  |  *    and/or other materials provided with the distribution. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 
					
						
							|  |  |  |  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
					
						
							|  |  |  |  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 
					
						
							|  |  |  |  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | 
					
						
							|  |  |  |  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
					
						
							|  |  |  |  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 
					
						
							|  |  |  |  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | 
					
						
							|  |  |  |  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 
					
						
							|  |  |  |  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
					
						
							|  |  |  |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-06 15:04:03 +01:00
										 |  |  | #include <LibCore/Gzip.h>
 | 
					
						
							|  |  |  | #include <LibCore/HttpJob.h>
 | 
					
						
							|  |  |  | #include <LibCore/HttpResponse.h>
 | 
					
						
							|  |  |  | #include <LibCore/TCPSocket.h>
 | 
					
						
							| 
									
										
										
										
											2019-04-07 14:36:10 +02:00
										 |  |  | #include <stdio.h>
 | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  | #include <unistd.h>
 | 
					
						
							| 
									
										
										
										
											2019-04-07 14:36:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-14 11:30:18 +01:00
										 |  |  | //#define CHTTPJOB_DEBUG
 | 
					
						
							| 
									
										
										
										
											2019-10-15 19:14:11 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  | namespace Core { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-09 18:33:37 +01:00
										 |  |  | static ByteBuffer handle_content_encoding(const ByteBuffer& buf, const String& content_encoding) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-12-14 11:30:18 +01:00
										 |  |  | #ifdef CHTTPJOB_DEBUG
 | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |     dbg() << "HttpJob::handle_content_encoding: buf has content_encoding = " << content_encoding; | 
					
						
							| 
									
										
										
										
											2019-12-14 11:30:18 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2019-11-09 18:33:37 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (content_encoding == "gzip") { | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |         if (!Gzip::is_compressed(buf)) { | 
					
						
							|  |  |  |             dbg() << "HttpJob::handle_content_encoding: buf is not gzip compressed!"; | 
					
						
							| 
									
										
										
										
											2019-11-09 18:33:37 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-14 11:30:18 +01:00
										 |  |  | #ifdef CHTTPJOB_DEBUG
 | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |         dbg() << "HttpJob::handle_content_encoding: buf is gzip compressed!"; | 
					
						
							| 
									
										
										
										
											2019-12-14 11:30:18 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2019-11-09 18:33:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |         auto uncompressed = Gzip::decompress(buf); | 
					
						
							| 
									
										
										
										
											2019-11-09 18:33:37 +01:00
										 |  |  |         if (!uncompressed.has_value()) { | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |             dbg() << "HttpJob::handle_content_encoding: Gzip::decompress() failed. Returning original buffer."; | 
					
						
							| 
									
										
										
										
											2019-11-09 18:33:37 +01:00
										 |  |  |             return buf; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-14 11:30:18 +01:00
										 |  |  | #ifdef CHTTPJOB_DEBUG
 | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |         dbg() << "HttpJob::handle_content_encoding: Gzip::decompress() successful.\n" | 
					
						
							| 
									
										
										
										
											2019-11-09 18:33:37 +01:00
										 |  |  |               << "  Input size = " << buf.size() << "\n" | 
					
						
							|  |  |  |               << "  Output size = " << uncompressed.value().size(); | 
					
						
							| 
									
										
										
										
											2019-12-14 11:30:18 +01:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2019-11-09 18:33:37 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return uncompressed.value(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return buf; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  | HttpJob::HttpJob(const HttpRequest& request) | 
					
						
							| 
									
										
										
										
											2019-04-07 14:36:10 +02:00
										 |  |  |     : m_request(request) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  | HttpJob::~HttpJob() | 
					
						
							| 
									
										
										
										
											2019-04-07 14:36:10 +02:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  | void HttpJob::on_socket_connected() | 
					
						
							| 
									
										
										
										
											2019-04-07 14:36:10 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     auto raw_request = m_request.to_raw_request(); | 
					
						
							| 
									
										
										
										
											2019-04-08 04:53:45 +02:00
										 |  |  | #if 0
 | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |     dbg() << "HttpJob: raw_request:"; | 
					
						
							| 
									
										
										
										
											2019-08-04 22:10:54 +02:00
										 |  |  |     dbg() << String::copy(raw_request).characters(); | 
					
						
							| 
									
										
										
										
											2019-04-08 04:53:45 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2019-04-07 14:36:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-08 04:53:45 +02:00
										 |  |  |     bool success = m_socket->send(raw_request); | 
					
						
							| 
									
										
										
										
											2019-04-07 14:36:10 +02:00
										 |  |  |     if (!success) | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  |         return deferred_invoke([this](auto&) { did_fail(NetworkJob::Error::TransmissionFailed); }); | 
					
						
							| 
									
										
										
										
											2019-04-07 14:36:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-04 18:55:52 +02:00
										 |  |  |     m_socket->on_ready_to_read = [&] { | 
					
						
							| 
									
										
										
										
											2019-09-21 17:32:26 +02:00
										 |  |  |         if (is_cancelled()) | 
					
						
							|  |  |  |             return; | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |         if (m_state == State::InStatus) { | 
					
						
							| 
									
										
										
										
											2019-08-04 18:55:52 +02:00
										 |  |  |             if (!m_socket->can_read_line()) | 
					
						
							|  |  |  |                 return; | 
					
						
							| 
									
										
										
										
											2019-04-08 02:24:34 +02:00
										 |  |  |             auto line = m_socket->read_line(PAGE_SIZE); | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |             if (line.is_null()) { | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |                 fprintf(stderr, "HttpJob: Expected HTTP status\n"); | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  |                 return deferred_invoke([this](auto&) { did_fail(NetworkJob::Error::TransmissionFailed); }); | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2019-04-20 14:13:40 +02:00
										 |  |  |             auto parts = String::copy(line, Chomp).split(' '); | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |             if (parts.size() < 3) { | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |                 fprintf(stderr, "HttpJob: Expected 3-part HTTP status, got '%s'\n", line.data()); | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  |                 return deferred_invoke([this](auto&) { did_fail(NetworkJob::Error::ProtocolFailed); }); | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |             bool ok; | 
					
						
							|  |  |  |             m_code = parts[1].to_uint(ok); | 
					
						
							|  |  |  |             if (!ok) { | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |                 fprintf(stderr, "HttpJob: Expected numeric HTTP status\n"); | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  |                 return deferred_invoke([this](auto&) { did_fail(NetworkJob::Error::ProtocolFailed); }); | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |             m_state = State::InHeaders; | 
					
						
							| 
									
										
										
										
											2019-08-04 18:55:52 +02:00
										 |  |  |             return; | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |         if (m_state == State::InHeaders) { | 
					
						
							| 
									
										
										
										
											2019-08-04 18:55:52 +02:00
										 |  |  |             if (!m_socket->can_read_line()) | 
					
						
							|  |  |  |                 return; | 
					
						
							| 
									
										
										
										
											2019-04-08 02:24:34 +02:00
										 |  |  |             auto line = m_socket->read_line(PAGE_SIZE); | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |             if (line.is_null()) { | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |                 fprintf(stderr, "HttpJob: Expected HTTP header\n"); | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  |                 return did_fail(NetworkJob::Error::ProtocolFailed); | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2019-04-20 14:13:40 +02:00
										 |  |  |             auto chomped_line = String::copy(line, Chomp); | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |             if (chomped_line.is_empty()) { | 
					
						
							|  |  |  |                 m_state = State::InBody; | 
					
						
							| 
									
										
										
										
											2019-08-04 18:55:52 +02:00
										 |  |  |                 return; | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |             auto parts = chomped_line.split(':'); | 
					
						
							|  |  |  |             if (parts.is_empty()) { | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |                 fprintf(stderr, "HttpJob: Expected HTTP header with key/value\n"); | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  |                 return deferred_invoke([this](auto&) { did_fail(NetworkJob::Error::ProtocolFailed); }); | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |             } | 
					
						
							|  |  |  |             auto name = parts[0]; | 
					
						
							|  |  |  |             if (chomped_line.length() < name.length() + 2) { | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |                 fprintf(stderr, "HttpJob: Malformed HTTP header: '%s' (%zu)\n", chomped_line.characters(), chomped_line.length()); | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  |                 return deferred_invoke([this](auto&) { did_fail(NetworkJob::Error::ProtocolFailed); }); | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2019-04-07 22:47:34 +02:00
										 |  |  |             auto value = chomped_line.substring(name.length() + 2, chomped_line.length() - name.length() - 2); | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |             m_headers.set(name, value); | 
					
						
							| 
									
										
										
										
											2019-10-15 19:14:11 +02:00
										 |  |  | #ifdef CHTTPJOB_DEBUG
 | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |             dbg() << "HttpJob: [" << name << "] = '" << value << "'"; | 
					
						
							| 
									
										
										
										
											2019-10-15 19:14:11 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2019-08-04 18:55:52 +02:00
										 |  |  |             return; | 
					
						
							| 
									
										
										
										
											2019-04-07 19:35:07 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |         ASSERT(m_state == State::InBody); | 
					
						
							| 
									
										
										
										
											2019-06-22 23:10:05 +02:00
										 |  |  |         ASSERT(m_socket->can_read()); | 
					
						
							| 
									
										
										
										
											2019-12-14 10:00:14 +01:00
										 |  |  |         auto payload = m_socket->receive(64 * KB); | 
					
						
							| 
									
										
										
										
											2019-04-07 14:36:10 +02:00
										 |  |  |         if (!payload) { | 
					
						
							| 
									
										
										
										
											2019-08-04 18:55:52 +02:00
										 |  |  |             if (m_socket->eof()) | 
					
						
							|  |  |  |                 return finish_up(); | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  |             return deferred_invoke([this](auto&) { did_fail(NetworkJob::Error::ProtocolFailed); }); | 
					
						
							| 
									
										
										
										
											2019-04-07 14:36:10 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-08-04 18:55:52 +02:00
										 |  |  |         m_received_buffers.append(payload); | 
					
						
							|  |  |  |         m_received_size += payload.size(); | 
					
						
							| 
									
										
										
										
											2019-06-22 23:10:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-04 09:25:14 +02:00
										 |  |  |         auto content_length_header = m_headers.get("Content-Length"); | 
					
						
							|  |  |  |         if (content_length_header.has_value()) { | 
					
						
							|  |  |  |             bool ok; | 
					
						
							| 
									
										
										
										
											2019-08-04 18:55:52 +02:00
										 |  |  |             if (m_received_size >= content_length_header.value().to_uint(ok) && ok) | 
					
						
							|  |  |  |                 return finish_up(); | 
					
						
							| 
									
										
										
										
											2019-06-22 23:10:05 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-08-04 18:55:52 +02:00
										 |  |  |     }; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-04-07 14:36:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  | void HttpJob::finish_up() | 
					
						
							| 
									
										
										
										
											2019-08-04 18:55:52 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     m_state = State::Finished; | 
					
						
							|  |  |  |     auto flattened_buffer = ByteBuffer::create_uninitialized(m_received_size); | 
					
						
							| 
									
										
										
										
											2019-08-04 14:54:25 +02:00
										 |  |  |     u8* flat_ptr = flattened_buffer.data(); | 
					
						
							| 
									
										
										
										
											2019-08-04 18:55:52 +02:00
										 |  |  |     for (auto& received_buffer : m_received_buffers) { | 
					
						
							| 
									
										
										
										
											2019-08-04 14:54:25 +02:00
										 |  |  |         memcpy(flat_ptr, received_buffer.data(), received_buffer.size()); | 
					
						
							|  |  |  |         flat_ptr += received_buffer.size(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-08-04 18:55:52 +02:00
										 |  |  |     m_received_buffers.clear(); | 
					
						
							| 
									
										
										
										
											2019-08-04 14:54:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-09 18:33:37 +01:00
										 |  |  |     auto content_encoding = m_headers.get("Content-Encoding"); | 
					
						
							|  |  |  |     if (content_encoding.has_value()) { | 
					
						
							|  |  |  |         flattened_buffer = handle_content_encoding(flattened_buffer, content_encoding.value()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  |     auto response = HttpResponse::create(m_code, move(m_headers), move(flattened_buffer)); | 
					
						
							| 
									
										
										
										
											2019-05-28 11:53:16 +02:00
										 |  |  |     deferred_invoke([this, response](auto&) { | 
					
						
							| 
									
										
										
										
											2019-04-07 14:36:10 +02:00
										 |  |  |         did_finish(move(response)); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-04-08 04:53:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  | void HttpJob::start() | 
					
						
							| 
									
										
										
										
											2019-04-08 04:53:45 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     ASSERT(!m_socket); | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  |     m_socket = TCPSocket::construct(this); | 
					
						
							| 
									
										
										
										
											2019-04-08 04:53:45 +02:00
										 |  |  |     m_socket->on_connected = [this] { | 
					
						
							| 
									
										
										
										
											2019-10-15 19:14:11 +02:00
										 |  |  | #ifdef CHTTPJOB_DEBUG
 | 
					
						
							| 
									
										
										
										
											2020-03-07 11:37:51 +13:00
										 |  |  |         dbg() << "HttpJob: on_connected callback"; | 
					
						
							| 
									
										
										
										
											2019-10-15 19:14:11 +02:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2019-04-08 04:53:45 +02:00
										 |  |  |         on_socket_connected(); | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2019-08-10 19:32:03 +02:00
										 |  |  |     bool success = m_socket->connect(m_request.url().host(), m_request.url().port()); | 
					
						
							| 
									
										
										
										
											2019-10-08 19:32:34 +02:00
										 |  |  |     if (!success) { | 
					
						
							|  |  |  |         deferred_invoke([this](auto&) { | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  |             return did_fail(NetworkJob::Error::ConnectionFailed); | 
					
						
							| 
									
										
										
										
											2019-10-08 19:32:34 +02:00
										 |  |  |         }); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-04-08 04:53:45 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-09-21 17:32:26 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  | void HttpJob::shutdown() | 
					
						
							| 
									
										
										
										
											2019-09-21 17:32:26 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     if (!m_socket) | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     m_socket->on_ready_to_read = nullptr; | 
					
						
							|  |  |  |     m_socket->on_connected = nullptr; | 
					
						
							| 
									
										
										
										
											2019-09-21 18:05:34 +02:00
										 |  |  |     remove_child(*m_socket); | 
					
						
							| 
									
										
										
										
											2019-09-21 17:32:26 +02:00
										 |  |  |     m_socket = nullptr; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-02-02 12:34:39 +01:00
										 |  |  | } |