File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -133,6 +133,10 @@ int QHttpConnection::HeadersComplete(http_parser *parser)
133133 /* * set headers **/
134134 theConnection->m_request ->setHeaders (theConnection->m_currentHeaders );
135135
136+ /* * set client information **/
137+ theConnection->m_request ->m_remoteAddress = theConnection->m_socket ->peerAddress ().toString ();
138+ theConnection->m_request ->m_remotePort = theConnection->m_socket ->peerPort ();
139+
136140 QHttpResponse *response = new QHttpResponse (theConnection);
137141 if ( parser->http_major < 1 || parser->http_minor < 1 )
138142 response->m_keepAlive = false ;
Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ class QHttpRequest : public QObject
5454 Q_OBJECT
5555
5656 Q_PROPERTY (HeaderHash headers READ headers);
57+ Q_PROPERTY (QString remoteAddress READ remoteAddress);
58+ Q_PROPERTY (quint16 remotePort READ remotePort);
5759
5860public:
5961 virtual ~QHttpRequest ();
@@ -120,6 +122,16 @@ class QHttpRequest : public QObject
120122 */
121123 QString header (const QString &field) { return m_headers[field]; };
122124
125+ /* !
126+ * IP Address of the client in dotted decimal format
127+ */
128+ const QString& remoteAddress () const { return m_remoteAddress; };
129+
130+ /* !
131+ * Outbound connection port for the client.
132+ */
133+ quint16 remotePort () const { return m_remotePort; };
134+
123135signals:
124136 /* !
125137 * This signal is emitted whenever body data is encountered
@@ -147,6 +159,8 @@ class QHttpRequest : public QObject
147159 QString m_method;
148160 QUrl m_url;
149161 QString m_version;
162+ QString m_remoteAddress;
163+ quint16 m_remotePort;
150164
151165 friend class QHttpConnection ;
152166};
You can’t perform that action at this time.
0 commit comments