webservices: Store headers in WsReadEnvelopeStart.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2017-09-06 15:56:05 +02:00 committed by Alexandre Julliard
parent a55d384264
commit ffbddae542
5 changed files with 50 additions and 9 deletions

View File

@ -315,21 +315,25 @@ HRESULT WINAPI WsGetHeapProperty( WS_HEAP *handle, WS_HEAP_PROPERTY_ID id, void
}
#define XML_BUFFER_INITIAL_ALLOCATED_SIZE 256
struct xmlbuf *alloc_xmlbuf( WS_HEAP *heap, WS_XML_WRITER_ENCODING_TYPE encoding, WS_CHARSET charset )
struct xmlbuf *alloc_xmlbuf( WS_HEAP *heap, SIZE_T size, WS_XML_WRITER_ENCODING_TYPE encoding, WS_CHARSET charset,
const WS_XML_DICTIONARY *dict_static, WS_XML_DICTIONARY *dict )
{
struct xmlbuf *ret;
if (!size) size = XML_BUFFER_INITIAL_ALLOCATED_SIZE;
if (!(ret = ws_alloc( heap, sizeof(*ret) ))) return NULL;
if (!(ret->bytes.bytes = ws_alloc( heap, XML_BUFFER_INITIAL_ALLOCATED_SIZE )))
if (!(ret->bytes.bytes = ws_alloc( heap, size )))
{
ws_free( heap, ret, sizeof(*ret) );
return NULL;
}
ret->heap = heap;
ret->size = XML_BUFFER_INITIAL_ALLOCATED_SIZE;
ret->size = size;
ret->bytes.length = 0;
ret->encoding = encoding;
ret->charset = charset;
ret->dict_static = dict_static;
ret->dict = dict;
return ret;
}
@ -348,10 +352,13 @@ HRESULT WINAPI WsCreateXmlBuffer( WS_HEAP *heap, const WS_XML_BUFFER_PROPERTY *p
{
struct xmlbuf *xmlbuf;
TRACE( "%p %p %u %p %p\n", heap, properties, count, handle, error );
if (error) FIXME( "ignoring error parameter\n" );
if (!heap || !handle) return E_INVALIDARG;
if (count) FIXME( "properties not implemented\n" );
if (!(xmlbuf = alloc_xmlbuf( heap, WS_XML_WRITER_ENCODING_TYPE_TEXT, WS_CHARSET_UTF8 )))
if (!(xmlbuf = alloc_xmlbuf( heap, 0, WS_XML_WRITER_ENCODING_TYPE_TEXT, WS_CHARSET_UTF8, NULL, NULL )))
{
return WS_E_QUOTA_EXCEEDED;
}

View File

@ -794,7 +794,6 @@ static HRESULT read_envelope_start( WS_XML_READER *reader )
{
for (;;)
{
/* FIXME: store headers */
if ((hr = WsReadNode( reader, NULL )) != S_OK) return hr;
if (match_current_element( reader, &body )) break;
}
@ -836,7 +835,8 @@ HRESULT WINAPI WsReadEnvelopeStart( WS_MESSAGE *handle, WS_XML_READER *reader, W
return WS_E_INVALID_OPERATION;
}
if ((hr = read_envelope_start( reader )) == S_OK)
if ((hr = read_envelope_start( reader )) == S_OK &&
(hr = create_header_buffer( reader, msg->heap, &msg->buf )) == S_OK)
{
msg->reader_body = reader;
msg->state = WS_MESSAGE_STATE_READING;

View File

@ -6931,6 +6931,8 @@ HRESULT WINAPI WsSetInputToBuffer( WS_XML_READER *handle, WS_XML_BUFFER *buffer,
reader->input_enc = xmlbuf->encoding;
reader->input_charset = xmlbuf->charset;
reader->dict_static = xmlbuf->dict_static;
reader->dict = xmlbuf->dict;
set_input_buffer( reader, xmlbuf, xmlbuf->bytes.bytes, xmlbuf->bytes.length );
if (!(node = alloc_node( WS_XML_NODE_TYPE_BOF ))) hr = E_OUTOFMEMORY;
@ -7268,6 +7270,33 @@ done:
return hr;
}
HRESULT create_header_buffer( WS_XML_READER *handle, WS_HEAP *heap, WS_XML_BUFFER **ret )
{
struct reader *reader = (struct reader *)handle;
HRESULT hr = WS_E_QUOTA_EXCEEDED;
struct xmlbuf *xmlbuf;
EnterCriticalSection( &reader->cs );
if (reader->magic != READER_MAGIC)
{
LeaveCriticalSection( &reader->cs );
return E_INVALIDARG;
}
if ((xmlbuf = alloc_xmlbuf( heap, reader->read_pos, reader->input_enc, reader->input_charset,
reader->dict_static, reader->dict )))
{
memcpy( xmlbuf->bytes.bytes, reader->read_bufptr, reader->read_pos );
xmlbuf->bytes.length = reader->read_pos;
*ret = (WS_XML_BUFFER *)xmlbuf;
hr = S_OK;
}
LeaveCriticalSection( &reader->cs );
return hr;
}
HRESULT get_param_desc( const WS_STRUCT_DESCRIPTION *desc, USHORT index, const WS_FIELD_DESCRIPTION **ret )
{
if (index >= desc->fieldCount) return E_INVALIDARG;

View File

@ -25,6 +25,8 @@ struct xmlbuf
SIZE_T size;
WS_XML_WRITER_ENCODING_TYPE encoding;
WS_CHARSET charset;
const WS_XML_DICTIONARY *dict_static;
WS_XML_DICTIONARY *dict;
};
void *ws_alloc( WS_HEAP *, SIZE_T ) DECLSPEC_HIDDEN;
@ -32,7 +34,8 @@ void *ws_alloc_zero( WS_HEAP *, SIZE_T ) DECLSPEC_HIDDEN;
void *ws_realloc( WS_HEAP *, void *, SIZE_T, SIZE_T ) DECLSPEC_HIDDEN;
void *ws_realloc_zero( WS_HEAP *, void *, SIZE_T, SIZE_T ) DECLSPEC_HIDDEN;
void ws_free( WS_HEAP *, void *, SIZE_T ) DECLSPEC_HIDDEN;
struct xmlbuf *alloc_xmlbuf( WS_HEAP *, WS_XML_WRITER_ENCODING_TYPE, WS_CHARSET ) DECLSPEC_HIDDEN;
struct xmlbuf *alloc_xmlbuf( WS_HEAP *, SIZE_T, WS_XML_WRITER_ENCODING_TYPE, WS_CHARSET,
const WS_XML_DICTIONARY *, WS_XML_DICTIONARY * ) DECLSPEC_HIDDEN;
void free_xmlbuf( struct xmlbuf * ) DECLSPEC_HIDDEN;
struct dictionary
@ -62,6 +65,7 @@ void restore_fpword( unsigned short ) DECLSPEC_HIDDEN;
ULONG get_type_size( WS_TYPE, const void * ) DECLSPEC_HIDDEN;
HRESULT read_header( WS_XML_READER *, const WS_XML_STRING *, const WS_XML_STRING *, WS_TYPE,
const void *, WS_READ_OPTION, WS_HEAP *, void *, ULONG ) DECLSPEC_HIDDEN;
HRESULT create_header_buffer( WS_XML_READER *, WS_HEAP *, WS_XML_BUFFER ** ) DECLSPEC_HIDDEN;
WS_XML_UTF8_TEXT *alloc_utf8_text( const BYTE *, ULONG ) DECLSPEC_HIDDEN;
WS_XML_UTF16_TEXT *alloc_utf16_text( const BYTE *, ULONG ) DECLSPEC_HIDDEN;

View File

@ -85,7 +85,7 @@ struct writer
WS_XML_WRITER_OUTPUT_TYPE output_type;
struct xmlbuf *output_buf;
WS_HEAP *output_heap;
WS_XML_DICTIONARY *dict;
const WS_XML_DICTIONARY *dict;
WS_DYNAMIC_STRING_CALLBACK dict_cb;
void *dict_cb_state;
ULONG prop_count;
@ -408,7 +408,8 @@ HRESULT WINAPI WsSetOutput( WS_XML_WRITER *handle, const WS_XML_WRITER_ENCODING
case WS_XML_WRITER_OUTPUT_TYPE_BUFFER:
{
struct xmlbuf *xmlbuf;
if (!(xmlbuf = alloc_xmlbuf( writer->output_heap, writer->output_enc, writer->output_charset )))
if (!(xmlbuf = alloc_xmlbuf( writer->output_heap, 0, writer->output_enc, writer->output_charset,
writer->dict, NULL )))
{
hr = WS_E_QUOTA_EXCEEDED;
goto done;