Changeset 12ef579a4576c2d52bc65063b48858887e0669da
- Timestamp:
- 01/08/10 22:32:46
(3 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1262989966 +0000
- git-parent:
[3c6693076116177913e70ff74448aeea19e7baf0]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1262989966 +0000
- Message:
self identifying script tags, refs #229
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3c66930 |
r12ef579 |
|
| 75 | 75 | } state; |
|---|
| 76 | 76 | int count; /* Number of jlog messages we need to read */ |
|---|
| | 77 | u_int32_t hack_inc_id; |
|---|
| 77 | 78 | noit_http_session_ctx *ctx; |
|---|
| 78 | 79 | struct realtime_tracker *rt; |
|---|
| … | … | |
| 107 | 108 | } |
|---|
| 108 | 109 | int |
|---|
| 109 | | stratcon_line_to_javascript(noit_http_session_ctx *ctx, char *buff) { |
|---|
| | 110 | stratcon_line_to_javascript(noit_http_session_ctx *ctx, char *buff, |
|---|
| | 111 | u_int32_t inc_id) { |
|---|
| 110 | 112 | char buffer[1024]; |
|---|
| 111 | 113 | char *scp, *ecp, *token; |
|---|
| … | … | |
| 114 | 116 | const char *v, *cb = NULL; |
|---|
| 115 | 117 | noit_hash_table json = NOIT_HASH_EMPTY; |
|---|
| 116 | | |
|---|
| | 118 | char s_inc_id[42]; |
|---|
| | 119 | |
|---|
| | 120 | snprintf(s_inc_id, sizeof(s_inc_id), "script-%08x", inc_id); |
|---|
| 117 | 121 | if(noit_hash_retrieve(&ctx->req.querystring, "cb", strlen("cb"), &vcb)) |
|---|
| 118 | 122 | cb = vcb; |
|---|
| … | … | |
| 162 | 166 | #define ra_write(a,b) if(noit_http_response_append(ctx, a, b) == noit_false) BAIL_HTTP_WRITE |
|---|
| 163 | 167 | |
|---|
| 164 | | snprintf(buffer, sizeof(buffer), "<script>%s({", cb); |
|---|
| | 168 | snprintf(buffer, sizeof(buffer), "<script id=\"%s\">%s({", s_inc_id, cb); |
|---|
| 165 | 169 | ra_write(buffer, strlen(buffer)); |
|---|
| 166 | 170 | |
|---|
| … | … | |
| 170 | 174 | } |
|---|
| 171 | 175 | /* Time */ |
|---|
| | 176 | noit_hash_store(&json, "script_id", 9, strdup(s_inc_id)); |
|---|
| 172 | 177 | noit_hash_store(&json, "type", 4, strdup("M")); |
|---|
| 173 | 178 | PROCESS_NEXT_FIELD(token,len); |
|---|
| … | … | |
| 369 | 374 | case REALTIME_HTTP_WANT_BODY: |
|---|
| 370 | 375 | FULLREAD(e, ctx, ctx->body_len); |
|---|
| 371 | | if(stratcon_line_to_javascript(ctx->ctx, ctx->buffer)) goto socket_error; |
|---|
| | 376 | if(stratcon_line_to_javascript(ctx->ctx, ctx->buffer, ctx->hack_inc_id++)) goto socket_error; |
|---|
| 372 | 377 | free(ctx->buffer); ctx->buffer = NULL; |
|---|
| 373 | 378 | ctx->state = REALTIME_HTTP_WANT_HEADER; |
|---|