Lines Matching defs:wsi
28 * Produce Apache-compatible log string for wsi, like this:
44 lws_prepare_access_log_info(struct lws *wsi, char *uri_ptr, int uri_len, int meth)
56 if (!wsi->a.vhost)
60 if (wsi->a.vhost->log_fd == (int)LWS_INVALID_FILE)
63 if (wsi->access_log_pending)
64 lws_access_log(wsi);
66 wsi->http.access_log.header_log = lws_malloc((unsigned int)l, "access log");
67 if (!wsi->http.access_log.header_log)
81 if (wsi->mux_substream)
82 me = lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP_COLON_METHOD);
97 nwsi = lws_get_network_wsi(wsi);
104 lws_snprintf(wsi->http.access_log.header_log, (size_t)l,
106 ta, da, me, uri, hver[wsi->http.request_version]);
108 //lwsl_notice("%s\n", wsi->http.access_log.header_log);
110 l = lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_USER_AGENT);
112 wsi->http.access_log.user_agent =
114 if (!wsi->http.access_log.user_agent) {
116 lws_free_set_NULL(wsi->http.access_log.header_log);
119 wsi->http.access_log.user_agent[0] = '\0';
121 if (lws_hdr_copy(wsi, wsi->http.access_log.user_agent, l + 4,
124 if (wsi->http.access_log.user_agent[m] == '\"')
125 wsi->http.access_log.user_agent[m] = '\'';
127 l = lws_hdr_total_length(wsi, WSI_TOKEN_HTTP_REFERER);
129 wsi->http.access_log.referrer = lws_malloc((unsigned int)l + 5, "referrer");
130 if (!wsi->http.access_log.referrer) {
132 lws_free_set_NULL(wsi->http.access_log.user_agent);
133 lws_free_set_NULL(wsi->http.access_log.header_log);
136 wsi->http.access_log.referrer[0] = '\0';
137 if (lws_hdr_copy(wsi, wsi->http.access_log.referrer,
141 if (wsi->http.access_log.referrer[m] == '\"')
142 wsi->http.access_log.referrer[m] = '\'';
144 wsi->access_log_pending = 1;
149 lws_access_log(struct lws *wsi)
151 char *p = wsi->http.access_log.user_agent, ass[512],
152 *p1 = wsi->http.access_log.referrer;
155 if (!wsi->a.vhost)
158 if (wsi->a.vhost->log_fd == (int)LWS_INVALID_FILE)
161 if (!wsi->access_log_pending)
164 if (!wsi->http.access_log.header_log)
179 wsi->http.access_log.header_log,
180 wsi->http.access_log.response,
181 wsi->http.access_log.sent, p1);
190 if ((int)write(wsi->a.vhost->log_fd, ass, (size_t)l) != l)
193 if (wsi->http.access_log.header_log) {
194 lws_free(wsi->http.access_log.header_log);
195 wsi->http.access_log.header_log = NULL;
197 if (wsi->http.access_log.user_agent) {
198 lws_free(wsi->http.access_log.user_agent);
199 wsi->http.access_log.user_agent = NULL;
201 if (wsi->http.access_log.referrer) {
202 lws_free(wsi->http.access_log.referrer);
203 wsi->http.access_log.referrer = NULL;
205 wsi->access_log_pending = 0;