You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by na...@apache.org on 2006/09/14 10:06:23 UTC
svn commit: r443282 - in /webservices/axis2/trunk/c/tools/tcpmon/src:
entry.c util.c
Author: nandika
Date: Thu Sep 14 01:06:22 2006
New Revision: 443282
URL: http://svn.apache.org/viewvc?view=rev&rev=443282
Log:
add tcpmon for text transfer mode support.
Modified:
webservices/axis2/trunk/c/tools/tcpmon/src/entry.c
webservices/axis2/trunk/c/tools/tcpmon/src/util.c
Modified: webservices/axis2/trunk/c/tools/tcpmon/src/entry.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/src/entry.c?view=diff&rev=443282&r1=443281&r2=443282
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/src/entry.c (original)
+++ webservices/axis2/trunk/c/tools/tcpmon/src/entry.c Thu Sep 14 01:06:22 2006
@@ -389,6 +389,27 @@
buffer = read_current_stream ( client_stream, env, &buffer_size,
&headers, &content );
+
+ now = time (NULL );
+ localTime = localtime ( &now);
+
+ sprintf (entry_impl-> sent_time, "%d:%d:%d" , localTime-> tm_hour, localTime-> tm_min,
+ localTime-> tm_sec );
+ sent_secs = localTime-> tm_hour * 60 * 60 +
+ localTime-> tm_min * 60 +
+ localTime-> tm_sec;
+
+ /*free ( localTime); */
+
+ entry_impl-> sent_headers = headers;
+ entry_impl-> sent_data = content;
+
+ if ( on_new_entry)
+ {
+ (on_new_entry)(env, entry, 0);
+ }
+
+
host_socket = axis2_network_handler_open_socket(env, target_host, target_port);
if ( -1 == host_socket )
@@ -424,28 +445,7 @@
}
return NULL;
}
-
- now = time (NULL );
- localTime = localtime ( &now);
-
- sprintf (entry_impl-> sent_time, "%d:%d:%d" , localTime-> tm_hour, localTime-> tm_min,
- localTime-> tm_sec );
- sent_secs = localTime-> tm_hour * 60 * 60 +
- localTime-> tm_min * 60 +
- localTime-> tm_sec;
-
- /*free ( localTime); */
-
- entry_impl-> sent_headers = headers;
- entry_impl-> sent_data = content;
-
- if ( on_new_entry)
- {
- (on_new_entry)(env, entry, 0);
- }
-
-
-
+
AXIS2_STREAM_WRITE ( host_stream, env, buffer , buffer_size);
AXIS2_FREE ( env-> allocator, buffer);
@@ -520,6 +520,7 @@
int line_just_ended = 1;
axis2_char_t *length_char= 0;
int length = -1;
+ int chunked_encoded = 0;
buffer = AXIS2_MALLOC ( env-> allocator, sizeof(axis2_char_t) );
@@ -528,7 +529,7 @@
buffer = AXIS2_REALLOC ( env-> allocator, buffer,
sizeof (axis2_char_t)* (read_size + 1) );
read = AXIS2_STREAM_READ ( stream, env , buffer + read_size, 1 );
-
+
if ( header_just_finished )
{
header_just_finished = 0;
@@ -562,12 +563,22 @@
{
length--;
}
+ if ( header_found &&
+ read_size >= 4 &&
+ chunked_encoded == 1 &&
+ *(buffer+read_size) == '\n' &&
+ *(buffer+read_size-1) == '\r' &&
+ *(buffer+read_size-2) == '\n' &&
+ *(buffer+read_size-3) == '\r' &&
+ *(buffer+read_size-4) == '0')
+ {
+ length = 0; /** this occurs in chunked transfer encoding */
+ }
/** identify the end of the header */
if ( !header_found &&
read_size >= 3 &&
*(buffer + read_size) == '\n' &&
- *(buffer + read_size) == '\n' &&
*(buffer + read_size -1 ) == '\r' &&
*(buffer + read_size -2 ) == '\n' &&
*(buffer + read_size -3 ) == '\r')
@@ -579,10 +590,17 @@
*(buffer + read_size-3) = '\r';
}
read_size ++;
- if ( length < -1 )
+ if ( !chunked_encoded && length < -1 )
{
header_width = 0;
- break;
+ /* break;*/
+ /** this is considered as transfer-encoding = chunked */
+ chunked_encoded = 1;
+ header_found = 1;
+ *(buffer + read_size-3) = '\0';
+ header_ptr = (axis2_char_t*)AXIS2_STRDUP (buffer, env );
+ header_just_finished = 1;
+ *(buffer + read_size-3) = '\r';
}
}
while ( length != 0 );
Modified: webservices/axis2/trunk/c/tools/tcpmon/src/util.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/tools/tcpmon/src/util.c?view=diff&rev=443282&r1=443281&r2=443282
==============================================================================
--- webservices/axis2/trunk/c/tools/tcpmon/src/util.c (original)
+++ webservices/axis2/trunk/c/tools/tcpmon/src/util.c Thu Sep 14 01:06:22 2006
@@ -27,6 +27,7 @@
axis2_char_t tmp;
int tabs = 0;
int xml_part_found = 0;
+ int indent_on_next_it = 0;
allocator = (tcpmon_util_allocator_t*) AXIS2_MALLOC(env->
allocator, sizeof(tcpmon_util_allocator_t));
@@ -50,6 +51,33 @@
}
}
xml_part_found = 1; /* we come here after we found xml */
+ /** ignore cases nothing to process */
+ for(; *p ==' ' || *p == '\n' || *p == '\r' || *p =='\t' ||
+ (*p > 'a' && *p < 'z') || /* simple letters */
+ (*p > 'A' && *p < 'Z') || /* capital letters */
+ (*p > '0' && *p < '9'); p ++)
+ {
+ /** new lines handle specially to keept the indentation */
+ if ( *p =='\n' )
+ {
+ /* surly there will be an iteration in next line, so dont do explicitly */
+ if ( indent_on_next_it)
+ {
+ flag = p+1;
+ }
+ else
+ {
+ tmp = *(p+1);
+ *(p+1) = '\0';
+ add_string ( env, allocator, flag );
+ *(p+1) = tmp;
+ flag = p+1;
+ add_axis2_char_t (env, allocator, '\n', 1);
+ add_axis2_char_t ( env, allocator, '\t', tabs );
+ }
+ }
+ }
+ indent_on_next_it = 0;
/** found a comment */
if ( *p == '<' && *(p+1) =='!' /**just continue since string conts */
&& *(p+2) =='-'
@@ -119,11 +147,14 @@
break;
}
- /** these are special case - new line would be set on next iterate */
- if ( *(p+1) =='<' && *(p+2) =='/' )
+ /** places like <this/> */
+ if( p != data && *(p-1) == '/')
{
+ tabs --;
}
- else if ( p !=data && *(p-1) =='?' ) /* ignore this case */
+
+ /** these are special case - new line would be set on next iterate */
+ if ( *(p+1) =='<' && *(p+2) =='/' )
{
}
else
@@ -136,6 +167,7 @@
add_axis2_char_t (env, allocator, '\n', 1);
add_axis2_char_t (env, allocator, '\t', tabs);
+ indent_on_next_it = 1;
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org