ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
September 2017
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
17 participants
284 discussions
Start a n
N
ew thread
[akhaldi] 75950: [XMLLITE] Sync with Wine Staging 2.16. CORE-13762 49a57bc xmllite/writer: Improve handling of the output with invalid encoding. a6d6beb xmllite/writer: Do not indent after just BOM...
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:18:39 2017 New Revision: 75950 URL:
http://svn.reactos.org/svn/reactos?rev=75950&view=rev
Log: [XMLLITE] Sync with Wine Staging 2.16. CORE-13762 49a57bc xmllite/writer: Improve handling of the output with invalid encoding. a6d6beb xmllite/writer: Do not indent after just BOM has been written. 5773a5d xmllite/writer: Fix indentation on WriteElementString(). 5f4ed88 xmllite/writer: Fix empty element and state handling in WriteElementString(). b06dd7d xmllite/reader: Added a helper for setting current attribute cursor. be56791 xmllite/reader: Implement MoveToAttributeByName(). Modified: trunk/reactos/dll/win32/xmllite/reader.c trunk/reactos/dll/win32/xmllite/writer.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/xmllite/reader.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/xmllite/reader.c…
============================================================================== --- trunk/reactos/dll/win32/xmllite/reader.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/xmllite/reader.c [iso-8859-1] Sun Sep 24 11:18:39 2017 @@ -146,7 +146,7 @@ static const struct xml_encoding_data xml_encoding_map[] = { { usasciiW, XmlEncoding_USASCII, 20127 }, - { utf16W, XmlEncoding_UTF16, ~0 }, + { utf16W, XmlEncoding_UTF16, 1200 }, { utf8W, XmlEncoding_UTF8, CP_UTF8 }, }; @@ -511,6 +511,19 @@ reader->is_empty_element = FALSE; } +static struct ns *reader_lookup_ns(xmlreader *reader, const strval *prefix) +{ + struct list *nslist = prefix ? &reader->ns : &reader->nsdef; + struct ns *ns; + + LIST_FOR_EACH_ENTRY_REV(ns, nslist, struct ns, entry) { + if (strval_eq(reader, prefix, &ns->prefix)) + return ns; + } + + return NULL; +} + static HRESULT reader_inc_depth(xmlreader *reader) { return (++reader->depth >= reader->max_depth && reader->max_depth) ? SC_E_MAXELEMENTDEPTH : S_OK; @@ -1061,7 +1074,7 @@ prev_len = dest->written / sizeof(WCHAR); /* just copy for UTF-16 case */ - if (cp == ~0) + if (cp == 1200) { readerinput_grow(readerinput, len); memcpy(dest->data + dest->written, src->data + src->cur, len); @@ -2928,6 +2941,15 @@ return This->state == XmlReadState_Closed ? S_FALSE : S_OK; } +static void reader_set_current_attribute(xmlreader *reader, struct attribute *attr) +{ + reader->attr = attr; + reader->chunk_read_off = 0; + reader_set_strvalue(reader, StringValue_Prefix, &attr->prefix); + reader_set_strvalue(reader, StringValue_QualifiedName, &attr->qname); + reader_set_strvalue(reader, StringValue_Value, &attr->value); +} + static HRESULT reader_move_to_first_attribute(xmlreader *reader) { if (!reader->attr_count) @@ -2936,11 +2958,7 @@ if (!reader->attr) reader_inc_depth(reader); - reader->attr = LIST_ENTRY(list_head(&reader->attrs), struct attribute, entry); - reader->chunk_read_off = 0; - reader_set_strvalue(reader, StringValue_Prefix, &reader->attr->prefix); - reader_set_strvalue(reader, StringValue_QualifiedName, &reader->attr->qname); - reader_set_strvalue(reader, StringValue_Value, &reader->attr->value); + reader_set_current_attribute(reader, LIST_ENTRY(list_head(&reader->attrs), struct attribute, entry)); return S_OK; } @@ -2968,23 +2986,111 @@ next = list_next(&This->attrs, &This->attr->entry); if (next) - { - This->attr = LIST_ENTRY(next, struct attribute, entry); - This->chunk_read_off = 0; - reader_set_strvalue(This, StringValue_Prefix, &This->attr->prefix); - reader_set_strvalue(This, StringValue_QualifiedName, &This->attr->qname); - reader_set_strvalue(This, StringValue_Value, &This->attr->value); - } + reader_set_current_attribute(This, LIST_ENTRY(next, struct attribute, entry)); return next ? S_OK : S_FALSE; } +static void reader_get_attribute_ns_uri(xmlreader *reader, struct attribute *attr, const WCHAR **uri, UINT *len) +{ + static const WCHAR xmlns_uriW[] = {'h','t','t','p',':','/','/','w','w','w','.','w','3','.','o','r','g','/', + '2','0','0','0','/','x','m','l','n','s','/',0}; + static const WCHAR xml_uriW[] = {'h','t','t','p',':','/','/','w','w','w','.','w','3','.','o','r','g','/', + 'X','M','L','/','1','9','9','8','/','n','a','m','e','s','p','a','c','e',0}; + + /* Check for reserved prefixes first */ + if ((strval_eq(reader, &attr->prefix, &strval_empty) && strval_eq(reader, &attr->localname, &strval_xmlns)) || + strval_eq(reader, &attr->prefix, &strval_xmlns)) + { + *uri = xmlns_uriW; + *len = sizeof(xmlns_uriW)/sizeof(xmlns_uriW[0]) - 1; + } + else if (strval_eq(reader, &attr->prefix, &strval_xml)) + { + *uri = xml_uriW; + *len = sizeof(xml_uriW)/sizeof(xml_uriW[0]) - 1; + } + else + { + *uri = NULL; + *len = 0; + } + + if (!*uri) + { + struct ns *ns; + + if ((ns = reader_lookup_ns(reader, &attr->prefix))) + { + *uri = ns->uri.str; + *len = ns->uri.len; + } + else + { + *uri = emptyW; + *len = 0; + } + } +} + +static void reader_get_attribute_local_name(xmlreader *reader, struct attribute *attr, const WCHAR **name, UINT *len) +{ + if (attr->flags & ATTRIBUTE_DEFAULT_NS_DEFINITION) + { + *name = xmlnsW; + *len = 5; + } + else if (attr->flags & ATTRIBUTE_NS_DEFINITION) + { + const struct ns *ns = reader_lookup_ns(reader, &attr->localname); + *name = ns->prefix.str; + *len = ns->prefix.len; + } + else + { + *name = attr->localname.str; + *len = attr->localname.len; + } +} + static HRESULT WINAPI xmlreader_MoveToAttributeByName(IXmlReader* iface, - LPCWSTR local_name, - LPCWSTR namespaceUri) -{ - FIXME("(%p %p %p): stub\n", iface, local_name, namespaceUri); - return E_NOTIMPL; + const WCHAR *local_name, const WCHAR *namespace_uri) +{ + xmlreader *This = impl_from_IXmlReader(iface); + UINT target_name_len, target_uri_len; + struct attribute *attr; + + TRACE("(%p)->(%s %s)\n", This, debugstr_w(local_name), debugstr_w(namespace_uri)); + + if (!local_name) + return E_INVALIDARG; + + if (!This->attr_count) + return S_FALSE; + + if (!namespace_uri) + namespace_uri = emptyW; + + target_name_len = strlenW(local_name); + target_uri_len = strlenW(namespace_uri); + + LIST_FOR_EACH_ENTRY(attr, &This->attrs, struct attribute, entry) + { + UINT name_len, uri_len; + const WCHAR *name, *uri; + + reader_get_attribute_local_name(This, attr, &name, &name_len); + reader_get_attribute_ns_uri(This, attr, &uri, &uri_len); + + if (name_len == target_name_len && uri_len == target_uri_len && + !strcmpW(name, local_name) && !strcmpW(uri, namespace_uri)) + { + reader_set_current_attribute(This, attr); + return S_OK; + } + } + + return S_FALSE; } static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface) @@ -3078,19 +3184,6 @@ return S_OK; } -static struct ns *reader_lookup_ns(xmlreader *reader, const strval *prefix) -{ - struct list *nslist = prefix ? &reader->ns : &reader->nsdef; - struct ns *ns; - - LIST_FOR_EACH_ENTRY_REV(ns, nslist, struct ns, entry) { - if (strval_eq(reader, prefix, &ns->prefix)) - return ns; - } - - return NULL; -} - static struct ns *reader_lookup_nsdef(xmlreader *reader) { if (list_empty(&reader->nsdef)) @@ -3112,42 +3205,10 @@ if (!len) len = &length; - *uri = NULL; - *len = 0; - switch ((nodetype = reader_get_nodetype(This))) { case XmlNodeType_Attribute: - { - static const WCHAR xmlns_uriW[] = {'h','t','t','p',':','/','/','w','w','w','.','w','3','.','o','r','g','/', - '2','0','0','0','/','x','m','l','n','s','/',0}; - static const WCHAR xml_uriW[] = {'h','t','t','p',':','/','/','w','w','w','.','w','3','.','o','r','g','/', - 'X','M','L','/','1','9','9','8','/','n','a','m','e','s','p','a','c','e',0}; - - /* check for reserved prefixes first */ - if ((strval_eq(This, prefix, &strval_empty) && strval_eq(This, &This->attr->localname, &strval_xmlns)) || - strval_eq(This, prefix, &strval_xmlns)) - { - *uri = xmlns_uriW; - *len = sizeof(xmlns_uriW)/sizeof(xmlns_uriW[0]) - 1; - } - else if (strval_eq(This, prefix, &strval_xml)) { - *uri = xml_uriW; - *len = sizeof(xml_uriW)/sizeof(xml_uriW[0]) - 1; - } - - if (!*uri) { - ns = reader_lookup_ns(This, prefix); - if (ns) { - *uri = ns->uri.str; - *len = ns->uri.len; - } - else { - *uri = emptyW; - *len = 0; - } - } - } + reader_get_attribute_ns_uri(This, This->attr, uri, len); break; case XmlNodeType_Element: case XmlNodeType_EndElement: @@ -3179,6 +3240,8 @@ break; default: FIXME("Unhandled node type %d\n", nodetype); + *uri = NULL; + *len = 0; return E_NOTIMPL; } @@ -3212,22 +3275,7 @@ *len = element->localname.len; break; case XmlNodeType_Attribute: - if (This->attr->flags & ATTRIBUTE_DEFAULT_NS_DEFINITION) - { - *name = xmlnsW; - *len = 5; - } - else if (This->attr->flags & ATTRIBUTE_NS_DEFINITION) - { - const struct ns *ns = reader_lookup_ns(This, &This->attr->localname); - *name = ns->prefix.str; - *len = ns->prefix.len; - } - else - { - *name = This->attr->localname.str; - *len = This->attr->localname.len; - } + reader_get_attribute_local_name(This, This->attr, name, len); break; default: *name = This->strvalues[StringValue_LocalName].str; Modified: trunk/reactos/dll/win32/xmllite/writer.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/xmllite/writer.c…
============================================================================== --- trunk/reactos/dll/win32/xmllite/writer.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/xmllite/writer.c [iso-8859-1] Sun Sep 24 11:18:39 2017 @@ -30,6 +30,7 @@ #define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0])) static const WCHAR closeelementW[] = {'<','/'}; +static const WCHAR closetagW[] = {' ','/','>'}; static const WCHAR closepiW[] = {'?','>'}; static const WCHAR ltW[] = {'<'}; static const WCHAR gtW[] = {'>'}; @@ -46,13 +47,14 @@ typedef enum { - XmlWriterState_Initial, /* output is not set yet */ - XmlWriterState_Ready, /* SetOutput() was called, ready to start */ - XmlWriterState_PIDocStarted, /* document was started with manually added 'xml' PI */ - XmlWriterState_DocStarted, /* document was started with WriteStartDocument() */ - XmlWriterState_ElemStarted, /* writing element */ - XmlWriterState_Content, /* content is accepted at this point */ - XmlWriterState_DocClosed /* WriteEndDocument was called */ + XmlWriterState_Initial, /* output is not set yet */ + XmlWriterState_Ready, /* SetOutput() was called, ready to start */ + XmlWriterState_InvalidEncoding, /* SetOutput() was called, but output had invalid encoding */ + XmlWriterState_PIDocStarted, /* document was started with manually added 'xml' PI */ + XmlWriterState_DocStarted, /* document was started with WriteStartDocument() */ + XmlWriterState_ElemStarted, /* writing element */ + XmlWriterState_Content, /* content is accepted at this point */ + XmlWriterState_DocClosed /* WriteEndDocument was called */ } XmlWriterState; typedef struct @@ -197,11 +199,11 @@ { struct output_buffer *buffer = &output->buffer; const int initial_len = 0x2000; + UINT cp = ~0u; HRESULT hr; - UINT cp; - - hr = get_code_page(output->encoding, &cp); - if (FAILED(hr)) return hr; + + if (FAILED(hr = get_code_page(output->encoding, &cp))) + WARN("Failed to get code page for specified encoding.\n"); buffer->data = writeroutput_alloc(output, initial_len); if (!buffer->data) return E_OUTOFMEMORY; @@ -245,30 +247,30 @@ HRESULT hr; char *ptr; - if (buffer->codepage != ~0) { + if (buffer->codepage == 1200) { + /* For UTF-16 encoding just copy. */ + length = len == -1 ? strlenW(data) : len; + if (length) { + length *= sizeof(WCHAR); + + hr = grow_output_buffer(output, length); + if (FAILED(hr)) return hr; + ptr = buffer->data + buffer->written; + + memcpy(ptr, data, length); + buffer->written += length; + ptr += length; + /* null termination */ + *(WCHAR*)ptr = 0; + } + } + else { length = WideCharToMultiByte(buffer->codepage, 0, data, len, NULL, 0, NULL, NULL); hr = grow_output_buffer(output, length); if (FAILED(hr)) return hr; ptr = buffer->data + buffer->written; length = WideCharToMultiByte(buffer->codepage, 0, data, len, ptr, length, NULL, NULL); buffer->written += len == -1 ? length-1 : length; - } - else { - /* WCHAR data just copied */ - length = len == -1 ? strlenW(data) : len; - if (length) { - length *= sizeof(WCHAR); - - hr = grow_output_buffer(output, length); - if (FAILED(hr)) return hr; - ptr = buffer->data + buffer->written; - - memcpy(ptr, data, length); - buffer->written += length; - ptr += length; - /* null termination */ - *(WCHAR*)ptr = 0; - } } return S_OK; @@ -436,7 +438,9 @@ if (!writer->indent) return; - if (writer->output->buffer.written) + /* Do state check to prevent newline inserted after BOM. It is assumed that + state does not change between writing BOM and inserting indentation. */ + if (writer->output->buffer.written && writer->state != XmlWriterState_Ready) write_output_buffer(writer->output, crlfW, ARRAY_SIZE(crlfW)); while (indent_level--) write_output_buffer(writer->output, dblspaceW, ARRAY_SIZE(dblspaceW)); @@ -533,7 +537,6 @@ writeroutput, writeroutput->lpVtbl); IUnknown_Release(writeroutput); return E_FAIL; - } } @@ -544,7 +547,10 @@ This->output = impl_from_IXmlWriterOutput(writeroutput); } - This->state = XmlWriterState_Ready; + if (This->output->encoding == XmlEncoding_Unknown) + This->state = XmlWriterState_InvalidEncoding; + else + This->state = XmlWriterState_Ready; return writeroutput_query_for_stream(This->output); } @@ -630,6 +636,8 @@ case XmlWriterState_DocClosed: This->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; default: ; } @@ -677,6 +685,8 @@ case XmlWriterState_DocClosed: This->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; default: ; } @@ -718,6 +728,8 @@ { case XmlWriterState_Initial: return E_UNEXPECTED; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; case XmlWriterState_ElemStarted: writer_close_starttag(This); break; @@ -743,6 +755,8 @@ { case XmlWriterState_Initial: return E_UNEXPECTED; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; case XmlWriterState_DocClosed: return WR_E_INVALIDACTION; default: @@ -765,6 +779,8 @@ { case XmlWriterState_Initial: return E_UNEXPECTED; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; case XmlWriterState_ElemStarted: writer_close_starttag(This); break; @@ -822,29 +838,33 @@ { case XmlWriterState_Initial: return E_UNEXPECTED; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; case XmlWriterState_ElemStarted: writer_close_starttag(This); break; - case XmlWriterState_Ready: - case XmlWriterState_DocStarted: - case XmlWriterState_PIDocStarted: - break; - default: - This->state = XmlWriterState_DocClosed; - return WR_E_INVALIDACTION; + case XmlWriterState_DocClosed: + return WR_E_INVALIDACTION; + default: + ; } write_encoding_bom(This); + write_node_indent(This); write_output_buffer(This->output, ltW, ARRAY_SIZE(ltW)); write_output_qname(This->output, prefix, local_name); - write_output_buffer(This->output, gtW, ARRAY_SIZE(gtW)); if (value) + { + write_output_buffer(This->output, gtW, ARRAY_SIZE(gtW)); write_output_buffer(This->output, value, -1); - - write_output_buffer(This->output, closeelementW, ARRAY_SIZE(closeelementW)); - write_output_qname(This->output, prefix, local_name); - write_output_buffer(This->output, gtW, ARRAY_SIZE(gtW)); + write_output_buffer(This->output, closeelementW, ARRAY_SIZE(closeelementW)); + write_output_qname(This->output, prefix, local_name); + write_output_buffer(This->output, gtW, ARRAY_SIZE(gtW)); + } + else + write_output_buffer(This->output, closetagW, ARRAY_SIZE(closetagW)); + This->state = XmlWriterState_Content; return S_OK; @@ -864,6 +884,8 @@ case XmlWriterState_DocClosed: This->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; default: ; } @@ -891,6 +913,8 @@ case XmlWriterState_DocClosed: This->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; default: ; } @@ -901,8 +925,8 @@ writer_dec_indent(This); - if (This->starttagopen) { - static WCHAR closetagW[] = {' ','/','>'}; + if (This->starttagopen) + { write_output_buffer(This->output, closetagW, ARRAY_SIZE(closetagW)); This->starttagopen = FALSE; } @@ -927,6 +951,8 @@ { case XmlWriterState_Initial: return E_UNEXPECTED; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; case XmlWriterState_DocClosed: return WR_E_INVALIDACTION; default: @@ -951,6 +977,8 @@ case XmlWriterState_DocClosed: This->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; default: ; } @@ -990,6 +1018,8 @@ case XmlWriterState_DocClosed: This->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; default: ; } @@ -1011,6 +1041,8 @@ case XmlWriterState_DocClosed: This->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; default: ; } @@ -1051,6 +1083,8 @@ { case XmlWriterState_Initial: return E_UNEXPECTED; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; case XmlWriterState_DocStarted: if (!strcmpW(name, xmlW)) return WR_E_INVALIDACTION; @@ -1087,6 +1121,8 @@ { case XmlWriterState_Initial: return E_UNEXPECTED; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; case XmlWriterState_DocClosed: return WR_E_INVALIDACTION; default: @@ -1115,6 +1151,8 @@ case XmlWriterState_DocStarted: case XmlWriterState_PIDocStarted: break; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; default: This->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; @@ -1134,6 +1172,8 @@ { case XmlWriterState_Initial: return E_UNEXPECTED; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; case XmlWriterState_DocClosed: return WR_E_INVALIDACTION; default: @@ -1158,6 +1198,8 @@ return S_OK; case XmlWriterState_Ready: break; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; default: This->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; @@ -1180,6 +1222,8 @@ { case XmlWriterState_Initial: return E_UNEXPECTED; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; case XmlWriterState_DocClosed: return WR_E_INVALIDACTION; default: @@ -1195,12 +1239,13 @@ return E_OUTOFMEMORY; write_encoding_bom(This); + write_node_indent(This); + This->state = XmlWriterState_ElemStarted; This->starttagopen = TRUE; push_element(This, element); - write_node_indent(This); write_output_buffer(This->output, ltW, ARRAY_SIZE(ltW)); write_output_qname(This->output, prefix, local_name); writer_inc_indent(This); @@ -1255,6 +1300,8 @@ case XmlWriterState_DocClosed: This->state = XmlWriterState_DocClosed; return WR_E_INVALIDACTION; + case XmlWriterState_InvalidEncoding: + return MX_E_ENCODING; default: ; } Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Sep 24 11:18:39 2017 @@ -218,7 +218,7 @@ reactos/dll/win32/xinput1_2 # Synced to WineStaging-2.9 reactos/dll/win32/xinput1_3 # Synced to WineStaging-2.9 reactos/dll/win32/xinput9_1_0 # Synced to WineStaging-2.9 -reactos/dll/win32/xmllite # Synced to WineStaging-2.9 +reactos/dll/win32/xmllite # Synced to WineStaging-2.16 reactos/dll/cpl/inetcpl # Synced to WineStaging-2.9
7 years, 3 months
1
0
0
0
[akhaldi] 75949: [WINTRUST] Sync with Wine Staging 2.16. CORE-13762 59a476e wintrust: use enhanced crypto provider in VerifyImageHash 9369e80 wintrust: Increase buffer size to silence a gcc warning.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:18:27 2017 New Revision: 75949 URL:
http://svn.reactos.org/svn/reactos?rev=75949&view=rev
Log: [WINTRUST] Sync with Wine Staging 2.16. CORE-13762 59a476e wintrust: use enhanced crypto provider in VerifyImageHash 9369e80 wintrust: Increase buffer size to silence a gcc warning. Modified: trunk/reactos/dll/win32/wintrust/asn.c trunk/reactos/dll/win32/wintrust/softpub.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/wintrust/asn.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wintrust/asn.c?r…
============================================================================== --- trunk/reactos/dll/win32/wintrust/asn.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wintrust/asn.c [iso-8859-1] Sun Sep 24 11:18:27 2017 @@ -1830,10 +1830,10 @@ /* The largest possible string for the first two components * is 2.175 (= 2 * 40 + 175 = 255), so this is big enough. */ - char firstTwo[6]; + char firstTwo[8]; const BYTE *ptr; - snprintf(firstTwo, sizeof(firstTwo), "%d.%d", + sprintf(firstTwo, "%d.%d", pbEncoded[1 + lenBytes] / 40, pbEncoded[1 + lenBytes] - (pbEncoded[1 + lenBytes] / 40) * 40); Modified: trunk/reactos/dll/win32/wintrust/softpub.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wintrust/softpub…
============================================================================== --- trunk/reactos/dll/win32/wintrust/softpub.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wintrust/softpub.c [iso-8859-1] Sun Sep 24 11:18:27 2017 @@ -339,7 +339,7 @@ if (!prov) { - if (!CryptAcquireContextW(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) + if (!CryptAcquireContextW(&prov, NULL, MS_ENH_RSA_AES_PROV_W, PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) return GetLastError(); release_prov = TRUE; } Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Sep 24 11:18:27 2017 @@ -206,7 +206,7 @@ reactos/dll/win32/winmm/midimap # Forked at Wine-20050628 reactos/dll/win32/winmm/wavemap # Forked at Wine-20050628 reactos/dll/win32/winscard # Synced to WineStaging-2.9 -reactos/dll/win32/wintrust # Synced to WineStaging-2.9 +reactos/dll/win32/wintrust # Synced to WineStaging-2.16 reactos/dll/win32/wldap32 # Synced to WineStaging-2.9 reactos/dll/win32/wmi # Synced to WineStaging-2.9 reactos/dll/win32/wmiutils # Synced to WineStaging-2.9
7 years, 3 months
1
0
0
0
[akhaldi] 75948: [WINMINE] Sync with Wine Staging 2.16. CORE-13762 ca8f056 winemine: Added Shift+LClick hotkey to uncover multiple cells. 9b90266 winemine: Mine random placing fix.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:18:18 2017 New Revision: 75948 URL:
http://svn.reactos.org/svn/reactos?rev=75948&view=rev
Log: [WINMINE] Sync with Wine Staging 2.16. CORE-13762 ca8f056 winemine: Added Shift+LClick hotkey to uncover multiple cells. 9b90266 winemine: Mine random placing fix. Modified: trunk/reactos/base/applications/games/winmine/main.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/base/applications/games/winmine/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/games/wi…
============================================================================== --- trunk/reactos/base/applications/games/winmine/main.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/games/winmine/main.c [iso-8859-1] Sun Sep 24 11:18:18 2017 @@ -342,8 +342,8 @@ /* create mines */ i = 0; while( (unsigned) i < p_board->mines ) { - col = (int) (p_board->cols * (float) rand() / RAND_MAX + 1); - row = (int) (p_board->rows * (float) rand() / RAND_MAX + 1); + col = rand() % p_board->cols + 1; + row = rand() % p_board->rows + 1; if( !p_board->box[col][row].IsMine ) { i++; @@ -883,7 +883,7 @@ case WM_LBUTTONDOWN: WINE_TRACE("WM_LBUTTONDOWN\n"); - if( wParam & MK_RBUTTON ) + if( wParam & ( MK_RBUTTON | MK_SHIFT ) ) msg = WM_MBUTTONDOWN; TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); SetCapture( hWnd ); @@ -891,7 +891,7 @@ case WM_LBUTTONUP: WINE_TRACE("WM_LBUTTONUP\n"); - if( wParam & MK_RBUTTON ) + if( wParam & ( MK_RBUTTON | MK_SHIFT ) ) msg = WM_MBUTTONUP; TestBoard( hWnd, &board, (short)LOWORD(lParam), (short)HIWORD(lParam), msg ); ReleaseCapture(); Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Sep 24 11:18:18 2017 @@ -233,7 +233,7 @@ reactos/base/applications/cmdutils/wmic # Synced to WineStaging-2.9 reactos/base/applications/cmdutils/wscript # Synced to WineStaging-2.9 reactos/base/applications/cmdutils/xcopy # Synced to WineStaging-2.9 -reactos/base/applications/games/winmine # Synced to WineStaging-1.9.16 with our own resources. +reactos/base/applications/games/winmine # Synced to WineStaging-2.16 with our own resources. reactos/base/applications/extrac32 # Synced to WineStaging-2.9 reactos/base/applications/iexplore # Synced to WineStaging-2.9 reactos/base/applications/notepad # Forked at Wine-20041201
7 years, 3 months
1
0
0
0
[akhaldi] 75947: [WININET_WINETEST] Sync with Wine Staging 2.16. CORE-13762
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:18:11 2017 New Revision: 75947 URL:
http://svn.reactos.org/svn/reactos?rev=75947&view=rev
Log: [WININET_WINETEST] Sync with Wine Staging 2.16. CORE-13762 Modified: trunk/rostests/winetests/wininet/http.c Modified: trunk/rostests/winetests/wininet/http.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wininet/http.c?…
============================================================================== --- trunk/rostests/winetests/wininet/http.c [iso-8859-1] (original) +++ trunk/rostests/winetests/wininet/http.c [iso-8859-1] Sun Sep 24 11:18:11 2017 @@ -114,7 +114,7 @@ wine_allow[MAX_INTERNET_STATUS], notified[MAX_INTERNET_STATUS]; static const char *status_string[MAX_INTERNET_STATUS]; -static HANDLE hCompleteEvent, conn_close_event, conn_wait_event, server_req_rec_event; +static HANDLE complete_event, conn_close_event, conn_wait_event, server_req_rec_event, request_sent_event; static DWORD req_error; static BOOL is_ie7plus = TRUE; @@ -200,6 +200,33 @@ return proxy_enable != 0; } +static void init_events(void) +{ + complete_event = CreateEventW(NULL, FALSE, FALSE, NULL); + conn_close_event = CreateEventW(NULL, FALSE, FALSE, NULL); + conn_wait_event = CreateEventW(NULL, FALSE, FALSE, NULL); + server_req_rec_event = CreateEventW(NULL, FALSE, FALSE, NULL); + request_sent_event = CreateEventW(NULL, FALSE, FALSE, NULL); +} + +static void free_events(void) +{ + CloseHandle(complete_event); + CloseHandle(conn_close_event); + CloseHandle(conn_wait_event); + CloseHandle(server_req_rec_event); + CloseHandle(request_sent_event); +} + +static void reset_events(void) +{ + ResetEvent(complete_event); + ResetEvent(conn_close_event); + ResetEvent(conn_wait_event); + ResetEvent(server_req_rec_event); + ResetEvent(request_sent_event); +} + #define test_status_code(a,b) _test_status_code(__LINE__,a,b, FALSE) #define test_status_code_todo(a,b) _test_status_code(__LINE__,a,b, TRUE) static void _test_status_code(unsigned line, HINTERNET req, DWORD excode, BOOL is_todo) @@ -292,6 +319,19 @@ ok_(__FILE__,line)(flags == exflags, "flags = %x, expected %x\n", flags, exflags); } +#define test_request_url(a,b) _test_request_url(__LINE__,a,b) +static void _test_request_url(unsigned line, HINTERNET req, const char *expected_url) +{ + char buf[INTERNET_MAX_URL_LENGTH]; + DWORD size = sizeof(buf); + BOOL res; + + res = InternetQueryOptionA(req, INTERNET_OPTION_URL, buf, &size); + ok_(__FILE__,line)(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError()); + ok_(__FILE__,line)(size == strlen(expected_url), "size = %u\n", size); + ok_(__FILE__,line)(!strcmp(buf, expected_url), "unexpected URL %s, expected %s\n", buf, expected_url); +} + #define test_http_version(a) _test_http_version(__LINE__,a) static void _test_http_version(unsigned line, HINTERNET req) { @@ -320,86 +360,99 @@ switch (dwInternetStatus) { case INTERNET_STATUS_RESOLVING_NAME: - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_RESOLVING_NAME \"%s\" %d\n", - GetCurrentThreadId(), hInternet, dwContext, - (LPCSTR)lpvStatusInformation,dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_RESOLVING_NAME \"%s\" %d\n", + GetCurrentThreadId(), hInternet, dwContext, + (LPCSTR)lpvStatusInformation,dwStatusInformationLength); *(LPSTR)lpvStatusInformation = '\0'; break; case INTERNET_STATUS_NAME_RESOLVED: - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_NAME_RESOLVED \"%s\" %d\n", - GetCurrentThreadId(), hInternet, dwContext, - (LPCSTR)lpvStatusInformation,dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_NAME_RESOLVED \"%s\" %d\n", + GetCurrentThreadId(), hInternet, dwContext, + (LPCSTR)lpvStatusInformation,dwStatusInformationLength); *(LPSTR)lpvStatusInformation = '\0'; break; case INTERNET_STATUS_CONNECTING_TO_SERVER: - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTING_TO_SERVER \"%s\" %d\n", - GetCurrentThreadId(), hInternet, dwContext, - (LPCSTR)lpvStatusInformation,dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTING_TO_SERVER \"%s\" %d\n", + GetCurrentThreadId(), hInternet, dwContext, + (LPCSTR)lpvStatusInformation,dwStatusInformationLength); ok(dwStatusInformationLength == strlen(lpvStatusInformation)+1, "unexpected size %u\n", dwStatusInformationLength); *(LPSTR)lpvStatusInformation = '\0'; break; case INTERNET_STATUS_CONNECTED_TO_SERVER: - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTED_TO_SERVER \"%s\" %d\n", - GetCurrentThreadId(), hInternet, dwContext, - (LPCSTR)lpvStatusInformation,dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTED_TO_SERVER \"%s\" %d\n", + GetCurrentThreadId(), hInternet, dwContext, + (LPCSTR)lpvStatusInformation,dwStatusInformationLength); ok(dwStatusInformationLength == strlen(lpvStatusInformation)+1, "unexpected size %u\n", dwStatusInformationLength); *(LPSTR)lpvStatusInformation = '\0'; break; case INTERNET_STATUS_SENDING_REQUEST: - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_SENDING_REQUEST %p %d\n", - GetCurrentThreadId(), hInternet, dwContext, - lpvStatusInformation,dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_SENDING_REQUEST %p %d\n", + GetCurrentThreadId(), hInternet, dwContext, + lpvStatusInformation,dwStatusInformationLength); break; case INTERNET_STATUS_REQUEST_SENT: ok(dwStatusInformationLength == sizeof(DWORD), "info length should be sizeof(DWORD) instead of %d\n", dwStatusInformationLength); - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_REQUEST_SENT 0x%x %d\n", - GetCurrentThreadId(), hInternet, dwContext, - *(DWORD *)lpvStatusInformation,dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_REQUEST_SENT 0x%x %d\n", + GetCurrentThreadId(), hInternet, dwContext, + *(DWORD *)lpvStatusInformation,dwStatusInformationLength); break; case INTERNET_STATUS_RECEIVING_RESPONSE: - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_RECEIVING_RESPONSE %p %d\n", - GetCurrentThreadId(), hInternet, dwContext, - lpvStatusInformation,dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_RECEIVING_RESPONSE %p %d\n", + GetCurrentThreadId(), hInternet, dwContext, + lpvStatusInformation,dwStatusInformationLength); break; case INTERNET_STATUS_RESPONSE_RECEIVED: ok(dwStatusInformationLength == sizeof(DWORD), "info length should be sizeof(DWORD) instead of %d\n", dwStatusInformationLength); - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_RESPONSE_RECEIVED 0x%x %d\n", - GetCurrentThreadId(), hInternet, dwContext, - *(DWORD *)lpvStatusInformation,dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_RESPONSE_RECEIVED 0x%x %d\n", + GetCurrentThreadId(), hInternet, dwContext, + *(DWORD *)lpvStatusInformation,dwStatusInformationLength); break; case INTERNET_STATUS_CTL_RESPONSE_RECEIVED: - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CTL_RESPONSE_RECEIVED %p %d\n", - GetCurrentThreadId(), hInternet,dwContext, - lpvStatusInformation,dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CTL_RESPONSE_RECEIVED %p %d\n", + GetCurrentThreadId(), hInternet,dwContext, + lpvStatusInformation,dwStatusInformationLength); break; case INTERNET_STATUS_PREFETCH: - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_PREFETCH %p %d\n", - GetCurrentThreadId(), hInternet, dwContext, - lpvStatusInformation,dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_PREFETCH %p %d\n", + GetCurrentThreadId(), hInternet, dwContext, + lpvStatusInformation,dwStatusInformationLength); break; case INTERNET_STATUS_CLOSING_CONNECTION: - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CLOSING_CONNECTION %p %d\n", - GetCurrentThreadId(), hInternet, dwContext, - lpvStatusInformation,dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CLOSING_CONNECTION %p %d\n", + GetCurrentThreadId(), hInternet, dwContext, + lpvStatusInformation,dwStatusInformationLength); break; case INTERNET_STATUS_CONNECTION_CLOSED: - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTION_CLOSED %p %d\n", - GetCurrentThreadId(), hInternet, dwContext, - lpvStatusInformation,dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_CONNECTION_CLOSED %p %d\n", + GetCurrentThreadId(), hInternet, dwContext, + lpvStatusInformation,dwStatusInformationLength); break; case INTERNET_STATUS_HANDLE_CREATED: ok(dwStatusInformationLength == sizeof(HINTERNET), "info length should be sizeof(HINTERNET) instead of %d\n", dwStatusInformationLength); - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_HANDLE_CREATED %p %d\n", - GetCurrentThreadId(), hInternet, dwContext, - *(HINTERNET *)lpvStatusInformation,dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_HANDLE_CREATED %p %d\n", + GetCurrentThreadId(), hInternet, dwContext, + *(HINTERNET *)lpvStatusInformation,dwStatusInformationLength); CLEAR_NOTIFIED(INTERNET_STATUS_DETECTING_PROXY); SET_EXPECT(INTERNET_STATUS_DETECTING_PROXY); break; @@ -407,11 +460,12 @@ ok(dwStatusInformationLength == sizeof(HINTERNET), "info length should be sizeof(HINTERNET) instead of %d\n", dwStatusInformationLength); - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_HANDLE_CLOSING %p %d\n", - GetCurrentThreadId(), hInternet, dwContext, - *(HINTERNET *)lpvStatusInformation, dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_HANDLE_CLOSING %p %d\n", + GetCurrentThreadId(), hInternet, dwContext, + *(HINTERNET *)lpvStatusInformation, dwStatusInformationLength); if(!InterlockedDecrement(&close_handle_cnt)) - SetEvent(hCompleteEvent); + SetEvent(complete_event); break; case INTERNET_STATUS_REQUEST_COMPLETE: { @@ -420,31 +474,35 @@ "info length should be sizeof(INTERNET_ASYNC_RESULT) instead of %d\n", dwStatusInformationLength); ok(iar->dwResult == 1 || iar->dwResult == 0, "iar->dwResult = %ld\n", iar->dwResult); - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_REQUEST_COMPLETE {%ld,%d} %d\n", - GetCurrentThreadId(), hInternet, dwContext, - iar->dwResult,iar->dwError,dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_REQUEST_COMPLETE {%ld,%d} %d\n", + GetCurrentThreadId(), hInternet, dwContext, + iar->dwResult,iar->dwError,dwStatusInformationLength); req_error = iar->dwError; if(!close_handle_cnt) - SetEvent(hCompleteEvent); + SetEvent(complete_event); break; } case INTERNET_STATUS_REDIRECT: - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_REDIRECT \"%s\" %d\n", - GetCurrentThreadId(), hInternet, dwContext, - (LPCSTR)lpvStatusInformation, dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_REDIRECT \"%s\" %d\n", + GetCurrentThreadId(), hInternet, dwContext, + (LPCSTR)lpvStatusInformation, dwStatusInformationLength); *(LPSTR)lpvStatusInformation = '\0'; CLEAR_NOTIFIED(INTERNET_STATUS_DETECTING_PROXY); SET_EXPECT(INTERNET_STATUS_DETECTING_PROXY); break; case INTERNET_STATUS_INTERMEDIATE_RESPONSE: - trace("%04x:Callback %p 0x%lx INTERNET_STATUS_INTERMEDIATE_RESPONSE %p %d\n", - GetCurrentThreadId(), hInternet, dwContext, - lpvStatusInformation, dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx INTERNET_STATUS_INTERMEDIATE_RESPONSE %p %d\n", + GetCurrentThreadId(), hInternet, dwContext, + lpvStatusInformation, dwStatusInformationLength); break; default: - trace("%04x:Callback %p 0x%lx %d %p %d\n", - GetCurrentThreadId(), hInternet, dwContext, dwInternetStatus, - lpvStatusInformation, dwStatusInformationLength); + if(winetest_debug > 1) + trace("%04x:Callback %p 0x%lx %d %p %d\n", + GetCurrentThreadId(), hInternet, dwContext, dwInternetStatus, + lpvStatusInformation, dwStatusInformationLength); } } @@ -493,7 +551,7 @@ return read; } -static void close_async_handle(HINTERNET handle, HANDLE complete_event, int handle_cnt) +static void close_async_handle(HINTERNET handle, int handle_cnt) { BOOL res; @@ -502,7 +560,7 @@ SET_EXPECT2(INTERNET_STATUS_HANDLE_CLOSING, handle_cnt); res = InternetCloseHandle(handle); ok(res, "InternetCloseHandle failed: %u\n", GetLastError()); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); CHECK_NOTIFIED2(INTERNET_STATUS_HANDLE_CLOSING, handle_cnt); } @@ -516,9 +574,8 @@ const char *types[2] = { "*", NULL }; HINTERNET hi, hic = 0, hor = 0; - hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); - trace("Starting InternetReadFile test with flags 0x%x on url %s\n",flags,test->url); + reset_events(); trace("InternetOpenA <--\n"); hi = InternetOpenA((test->flags & TESTF_COMPRESSED) ? "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" : "", @@ -562,11 +619,7 @@ if (hor == 0x0) goto abort; test_request_flags(hor, INTERNET_REQFLAG_NO_HEADERS); - - length = sizeof(buffer); - res = InternetQueryOptionA(hor, INTERNET_OPTION_URL, buffer, &length); - ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError()); - ok(!strcmp(buffer, test->url), "Wrong URL %s, expected %s\n", buffer, test->url); + test_request_url(hor, test->url); length = sizeof(buffer); res = HttpQueryInfoA(hor, HTTP_QUERY_RAW_HEADERS, buffer, &length, 0x0); @@ -629,7 +682,7 @@ trace("HttpSendRequestA <--\n"); if (flags & INTERNET_FLAG_ASYNC) { - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); } HeapFree(GetProcessHeap(), 0, post_data); @@ -727,10 +780,7 @@ ok(wbuffer[length2+1] == 0x7777, "Expected 0x7777, got %04X\n", wbuffer[length2+1]); ok(length2 == length, "Value should not have changed: %d != %d\n", length2, length); - length = sizeof(buffer); - res = InternetQueryOptionA(hor, INTERNET_OPTION_URL, buffer, &length); - ok(res, "InternetQueryOptionA(INTERNET_OPTION_URL) failed: %u\n", GetLastError()); - ok(!strcmp(buffer, test->redirected_url), "Wrong URL %s\n", buffer); + test_request_url(hor, test->redirected_url); index = 0; length = 0; @@ -768,7 +818,8 @@ GetLastError()); length = 100; - trace("Entering Query loop\n"); + if(winetest_debug > 1) + trace("Entering Query loop\n"); while (TRUE) { @@ -796,11 +847,12 @@ } else if (GetLastError() == ERROR_IO_PENDING) { - trace("PENDING\n"); + if(winetest_debug > 1) + trace("pending\n"); /* on some tests, InternetQueryDataAvailable returns non-zero length and ERROR_IO_PENDING */ if(!(test->flags & TESTF_CHUNKED)) ok(!length, "InternetQueryDataAvailable returned ERROR_IO_PENDING and %u length\n", length); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); exlen = length; ok(exlen, "length = 0\n"); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); @@ -815,7 +867,8 @@ } CLEAR_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); - trace("LENGTH %d\n", length); + if(winetest_debug > 1) + trace("length %u\n", length); if(test->flags & TESTF_CHUNKED) ok(length <= 8192, "length = %d, expected <= 8192\n", length); if (length) @@ -827,7 +880,8 @@ buffer[length]=0; - trace("ReadFile -> %s %i\n",res?"TRUE":"FALSE",length); + if(winetest_debug > 1) + trace("ReadFile -> %s %i\n", res ? "TRUE" : "FALSE", length); if(test->content) ok(!strcmp(buffer, test->content), "buffer = '%s', expected '%s'\n", buffer, test->content); @@ -843,9 +897,9 @@ CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTION_CLOSED, 2); } abort: - trace("aborting\n"); - close_async_handle(hi, hCompleteEvent, 2); - CloseHandle(hCompleteEvent); + if(winetest_debug > 1) + trace("aborting\n"); + close_async_handle(hi, 2); first_connection_to_test_url = FALSE; } @@ -974,9 +1028,8 @@ HINTERNET hi, hic = 0, hor = 0; INTERNET_BUFFERSA inetbuffers; - hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); - trace("Starting InternetReadFileExA test with flags 0x%x\n",flags); + reset_events(); trace("InternetOpenA <--\n"); hi = InternetOpenA("", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, flags); @@ -1055,7 +1108,7 @@ trace("HttpSendRequestA <--\n"); if (!rc && (GetLastError() == ERROR_IO_PENDING)) { - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); } @@ -1148,7 +1201,7 @@ ok(flags & INTERNET_FLAG_ASYNC, "Should not get ERROR_IO_PENDING without INTERNET_FLAG_ASYNC\n"); CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); CHECK_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); @@ -1194,8 +1247,7 @@ trace("Finished. Read %d bytes\n", length); abort: - close_async_handle(hi, hCompleteEvent, 2); - CloseHandle(hCompleteEvent); + close_async_handle(hi, 2); first_connection_to_test_url = FALSE; } @@ -1376,8 +1428,7 @@ BYTE cache_headers[] = "HTTP/1.1 200 OK\r\n\r\n"; trace("Testing cache read...\n"); - - hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); + reset_events(); for(i = 0; i < sizeof(content); i++) content[i] = '0' + (i%10); @@ -1446,7 +1497,7 @@ ok(!memcmp(content, buf, sizeof(content)), "unexpected content\n"); } - close_async_handle(session, hCompleteEvent, 2); + close_async_handle(session, 2); CLEAR_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER); CLEAR_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER); @@ -1458,8 +1509,6 @@ res = DeleteUrlCacheEntryA(cache_only_url); ok(res, "DeleteUrlCacheEntryA failed: %u\n", GetLastError()); - - CloseHandle(hCompleteEvent); } static void test_http_cache(void) @@ -2368,13 +2417,13 @@ send(c, msg, sizeof msg-1, 0); } else send(c, notokmsg, sizeof notokmsg-1, 0); - WaitForSingleObject(hCompleteEvent, 5000); + WaitForSingleObject(complete_event, 5000); } else { if (strstr(buffer, "Content-Length: 0")) send(c, msg, sizeof msg-1, 0); else send(c, notokmsg, sizeof notokmsg-1, 0); - WaitForSingleObject(hCompleteEvent, 5000); + WaitForSingleObject(complete_event, 5000); } } if (strstr(buffer, "GET /test_premature_disconnect")) @@ -3113,11 +3162,7 @@ ok(!ret, "HttpQueryInfo succeeded\n"); ok(err == ERROR_HTTP_HEADER_NOT_FOUND, "Expected error ERROR_HTTP_HEADER_NOT_FOUND, got %d\n", err); - size = sizeof(buffer) - 1; - memset(buffer, 0, sizeof(buffer)); - ret = InternetQueryOptionA(req, INTERNET_OPTION_URL, buffer, &size); - ok(ret, "InternetQueryOption failed\n"); - ok(!strcmp(full_url, buffer), "Expected %s, got %s\n", full_url, buffer); + test_request_url(req, full_url); ret = HttpAddRequestHeadersA(req, host_header_override, ~0u, HTTP_ADDREQ_FLAG_COALESCE); ok(ret, "HttpAddRequestHeaders failed\n"); @@ -3128,11 +3173,7 @@ ret = HttpQueryInfoA(req, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, &count); ok(ret, "HttpQueryInfo failed\n"); - size = sizeof(buffer) - 1; - memset(buffer, 0, sizeof(buffer)); - ret = InternetQueryOptionA(req, INTERNET_OPTION_URL, buffer, &size); - ok(ret, "InternetQueryOption failed\n"); - ok(!strcmp(full_url, buffer), "Expected %s, got %s\n", full_url, buffer); + test_request_url(req, full_url); ret = HttpSendRequestA(req, NULL, 0, NULL, 0); ok(ret, "HttpSendRequest failed\n"); @@ -3346,7 +3387,7 @@ HINTERNET session, connection, req; DWORD res; - hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); + reset_events(); session = InternetOpenA("", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC); ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError()); @@ -3378,7 +3419,7 @@ res = HttpSendRequestA(req, NULL, 0, NULL, 0); ok(!res && (GetLastError() == ERROR_IO_PENDING), "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n"); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); @@ -3408,7 +3449,7 @@ res = HttpSendRequestA(req, NULL, 0, NULL, 0); ok(!res && (GetLastError() == ERROR_IO_PENDING), "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n"); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); @@ -3438,7 +3479,7 @@ res = HttpSendRequestA(req, NULL, 0, NULL, 0); ok(!res && (GetLastError() == ERROR_IO_PENDING), "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n"); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); @@ -3458,8 +3499,7 @@ SET_WINE_ALLOW(INTERNET_STATUS_CLOSING_CONNECTION); SET_WINE_ALLOW(INTERNET_STATUS_CONNECTION_CLOSED); - close_async_handle(session, hCompleteEvent, 2); - CloseHandle(hCompleteEvent); + close_async_handle(session, 2); } static void test_successive_HttpSendRequest(int port) @@ -3467,7 +3507,7 @@ HINTERNET session, connection, req; DWORD res; - hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); + reset_events(); session = InternetOpenA("", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC); ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError()); @@ -3497,7 +3537,7 @@ res = HttpSendRequestA(req, NULL, 0, NULL, 0); ok(!res && (GetLastError() == ERROR_IO_PENDING), "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n"); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); @@ -3525,7 +3565,7 @@ res = HttpSendRequestA(req, NULL, 0, NULL, 0); ok(!res && (GetLastError() == ERROR_IO_PENDING), "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n"); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); @@ -3543,8 +3583,7 @@ SET_WINE_ALLOW(INTERNET_STATUS_CLOSING_CONNECTION); SET_WINE_ALLOW(INTERNET_STATUS_CONNECTION_CLOSED); - close_async_handle(session, hCompleteEvent, 2); - CloseHandle(hCompleteEvent); + close_async_handle(session, 2); } static void test_no_content(int port) @@ -3554,7 +3593,7 @@ trace("Testing 204 no content response...\n"); - hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); + reset_events(); session = InternetOpenA("", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC); ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError()); @@ -3587,7 +3626,7 @@ res = HttpSendRequestA(req, NULL, -1, NULL, 0); ok(!res && (GetLastError() == ERROR_IO_PENDING), "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n"); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); @@ -3599,8 +3638,7 @@ CHECK_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); - close_async_handle(session, hCompleteEvent, 2); - CloseHandle(hCompleteEvent); + close_async_handle(session, 2); /* * The connection should be closed before closing handle. This is true for most @@ -3618,8 +3656,7 @@ trace("Testing connection close connection...\n"); - hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); - conn_close_event = CreateEventW(NULL, FALSE, FALSE, NULL); + reset_events(); session = InternetOpenA("", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC); ok(session != NULL,"InternetOpen failed with error %u\n", GetLastError()); @@ -3650,7 +3687,7 @@ res = HttpSendRequestA(req, NULL, -1, NULL, 0); ok(!res && (GetLastError() == ERROR_IO_PENDING), "Asynchronous HttpSendRequest NOT returning 0 with error ERROR_IO_PENDING\n"); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); @@ -3687,9 +3724,9 @@ SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); SetEvent(conn_close_event); #ifdef ROSTESTS_73_FIXED - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); #else /* ROSTESTS_73_FIXED */ - ok(WaitForSingleObject(hCompleteEvent, 5000) == WAIT_OBJECT_0, "Wait timed out\n"); + ok(WaitForSingleObject(complete_event, 5000) == WAIT_OBJECT_0, "Wait timed out\n"); #endif /* ROSTESTS_73_FIXED */ ok(req_error == ERROR_SUCCESS, "req_error = %u\n", req_error); CLEAR_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); @@ -3697,8 +3734,7 @@ CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); - close_async_handle(session, hCompleteEvent, 2); - CloseHandle(hCompleteEvent); + close_async_handle(session, 2); } static void test_no_cache(int port) @@ -4595,24 +4631,21 @@ test_request_t req; BOOL ret; - hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); - + reset_events(); open_simple_request(&req, "localhost", port, "POST", "/test_request_content_length"); ret = HttpSendRequestA(req.request, NULL, 0, NULL, 0); ok(ret, "HttpSendRequest failed %u\n", GetLastError()); test_status_code(req.request, 200); - SetEvent(hCompleteEvent); + SetEvent(complete_event); ret = HttpSendRequestA(req.request, NULL, 0, data, sizeof(data)); ok(ret, "HttpSendRequest failed %u\n", GetLastError()); test_status_code(req.request, 200); - SetEvent(hCompleteEvent); - + SetEvent(complete_event); close_request(&req); - CloseHandle(hCompleteEvent); } static void test_accept_encoding(int port) @@ -4719,8 +4752,7 @@ DWORD res, count, bytes; BOOL ret; - hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); - conn_wait_event = CreateEventW(NULL, FALSE, FALSE, NULL); + reset_events(); /* test asynchronous InternetReadFileEx */ ses = InternetOpenA( "winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC ); @@ -4753,7 +4785,7 @@ ret = HttpSendRequestA( req, NULL, 0, NULL, 0 ); ok( !ret, "HttpSendRequestA unexpectedly succeeded\n" ); ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError() ); - WaitForSingleObject( hCompleteEvent, INFINITE ); + WaitForSingleObject( complete_event, INFINITE ); ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error ); CLEAR_NOTIFIED( INTERNET_STATUS_COOKIE_SENT ); @@ -4790,11 +4822,11 @@ SET_EXPECT( INTERNET_STATUS_REQUEST_COMPLETE ); if (!pending_reads++) { - res = WaitForSingleObject( hCompleteEvent, 0 ); + res = WaitForSingleObject( complete_event, 0 ); ok( res == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", res ); SetEvent( conn_wait_event ); } - res = WaitForSingleObject( hCompleteEvent, INFINITE ); + res = WaitForSingleObject( complete_event, INFINITE ); ok( res == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", res ); ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error ); todo_wine_if( pending_reads > 1 ) @@ -4810,7 +4842,7 @@ ok( pending_reads == 1, "expected 1 pending read, got %u\n", pending_reads ); ok( !strcmp(buffer, page1), "unexpected buffer content\n" ); - close_async_handle( ses, hCompleteEvent, 2 ); + close_async_handle( ses, 2 ); ResetEvent( conn_wait_event ); /* test asynchronous InternetReadFile */ @@ -4844,7 +4876,7 @@ ret = HttpSendRequestA( req, NULL, 0, NULL, 0 ); ok( !ret, "HttpSendRequestA unexpectedly succeeded\n" ); ok( GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError() ); - WaitForSingleObject( hCompleteEvent, INFINITE ); + WaitForSingleObject( complete_event, INFINITE ); ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error ); CLEAR_NOTIFIED( INTERNET_STATUS_COOKIE_SENT ); @@ -4878,11 +4910,11 @@ SET_EXPECT( INTERNET_STATUS_REQUEST_COMPLETE ); if (!pending_reads++) { - res = WaitForSingleObject( hCompleteEvent, 0 ); + res = WaitForSingleObject( complete_event, 0 ); ok( res == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", res ); SetEvent( conn_wait_event ); } - res = WaitForSingleObject( hCompleteEvent, INFINITE ); + res = WaitForSingleObject( complete_event, INFINITE ); ok( res == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", res ); ok( req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error ); todo_wine_if( pending_reads > 1 ) @@ -4898,15 +4930,30 @@ ok( pending_reads == 1, "expected 1 pending read, got %u\n", pending_reads ); ok( !strcmp(buffer, page1), "unexpected buffer content\n" ); - close_async_handle( ses, hCompleteEvent, 2 ); - - CloseHandle( hCompleteEvent ); - CloseHandle( conn_wait_event ); + close_async_handle( ses, 2 ); } static void server_send_string(const char *msg) { send(server_socket, msg, strlen(msg), 0); +} + +static size_t server_read_data(char *buf, size_t buf_size) +{ + return recv(server_socket, buf, buf_size, 0); +} + +#define server_read_request(a) _server_read_request(__LINE__,a) +static void _server_read_request(unsigned line, const char *expected_request) +{ + char buf[4000], *p; + size_t size; + + size = server_read_data(buf, sizeof(buf) - 1); + buf[size] = 0; + p = strstr(buf, "\r\n"); + if(p) *p = 0; + ok_(__FILE__,line)(p && !strcmp(buf, expected_request), "unexpected request %s\n", buf); } static BOOL skip_receive_notification_tests; @@ -4924,14 +4971,54 @@ callback(handle, context, status, info, info_size); received_response_size = *(DWORD*)info; break; + case INTERNET_STATUS_REQUEST_SENT: + callback(handle, context, status, info, info_size); + SetEvent(request_sent_event); + break; default: callback(handle, context, status, info, info_size); } } -static void open_read_test_request(int port, test_request_t *req, const char *response) +static void send_socket_request(test_request_t *req, BOOL new_connection) { BOOL ret; + + SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT); + SET_OPTIONAL(INTERNET_STATUS_DETECTING_PROXY); + if(new_connection) { + SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER); + SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER); + } + SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST); + SET_EXPECT(INTERNET_STATUS_REQUEST_SENT); + if(!skip_receive_notification_tests) + SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE); + + SetLastError(0xdeadbeef); + ret = HttpSendRequestA(req->request, NULL, 0, NULL, 0); + ok(!ret, "HttpSendRequestA unexpectedly succeeded\n"); + ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError()); + + if(new_connection) + WaitForSingleObject(server_req_rec_event, INFINITE); + WaitForSingleObject(request_sent_event, INFINITE); + + CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); + CLEAR_NOTIFIED(INTERNET_STATUS_DETECTING_PROXY); + if(new_connection) { + CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER); + CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER); + } + CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST); + CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT); +} + +static void open_socket_request(int port, test_request_t *req, const char *verb) +{ + /* We're connecting to new socket */ + if(!verb) + reset_events(); req->session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC); ok(req->session != NULL, "InternetOpenA failed\n"); @@ -4943,31 +5030,20 @@ CHECK_NOTIFIED(INTERNET_STATUS_HANDLE_CREATED ); SET_EXPECT(INTERNET_STATUS_HANDLE_CREATED); - req->request = HttpOpenRequestA(req->connection, "GET", "/socket", NULL, NULL, NULL, INTERNET_FLAG_RELOAD, 0xdeadbeef); + req->request = HttpOpenRequestA(req->connection, "GET", verb ? verb : "/socket", + NULL, NULL, NULL, INTERNET_FLAG_RELOAD, 0xdeadbeef); ok(req->request != NULL, "HttpOpenRequestA failed %u\n", GetLastError()); CHECK_NOTIFIED( INTERNET_STATUS_HANDLE_CREATED ); - SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT); - SET_OPTIONAL(INTERNET_STATUS_DETECTING_PROXY); - SET_EXPECT(INTERNET_STATUS_CONNECTING_TO_SERVER); - SET_EXPECT(INTERNET_STATUS_CONNECTED_TO_SERVER); - SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST); - SET_EXPECT(INTERNET_STATUS_REQUEST_SENT); + send_socket_request(req, !verb); +} + +static void open_read_test_request(int port, test_request_t *req, const char *response) +{ if(!skip_receive_notification_tests) SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE); - SetLastError(0xdeadbeef); - ret = HttpSendRequestA(req->request, NULL, 0, NULL, 0); - ok(!ret, "HttpSendRequestA unexpectedly succeeded\n"); - ok(GetLastError() == ERROR_IO_PENDING, "expected ERROR_IO_PENDING, got %u\n", GetLastError()); - - WaitForSingleObject(server_req_rec_event, INFINITE); - - CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); - CLEAR_NOTIFIED(INTERNET_STATUS_DETECTING_PROXY); - CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER); - CHECK_NOTIFIED(INTERNET_STATUS_CONNECTED_TO_SERVER); - CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST); + open_socket_request(port, req, NULL); if(!skip_receive_notification_tests) { SET_EXPECT(INTERNET_STATUS_RESPONSE_RECEIVED); @@ -4976,7 +5052,7 @@ SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); server_send_string(response); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); if(!skip_receive_notification_tests) { CHECK_NOTIFIED(INTERNET_STATUS_RECEIVING_RESPONSE); @@ -4984,14 +5060,13 @@ todo_wine ok(received_response_size == strlen(response), "received_response_size = %u\n", received_response_size); } - CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT); CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error); } #define readex_expect_sync_data_len(a,b,c,d,e,f,g) _readex_expect_sync_data_len(__LINE__,a,b,c,d,e,f,g) static void _readex_expect_sync_data_len(unsigned line, HINTERNET req, DWORD flags, INTERNET_BUFFERSW *buf, - DWORD buf_size, const char *exdata, DWORD len, BOOL expect_receive) + DWORD buf_size, const char *exdata, DWORD len, DWORD expect_receive) { BOOL ret; @@ -5078,7 +5153,7 @@ if(do_close_connection) close_connection(); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); if(!skip_receive_notification_tests) CHECK_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED); @@ -5128,7 +5203,7 @@ if(!skip_receive_notification_tests) SET_EXPECT(INTERNET_STATUS_RECEIVING_RESPONSE); - memset(buf->lpvBuffer, 0, buf_size); + memset(buf->lpvBuffer, 0, max(buf_size, sizeof(DWORD))); buf->dwBufferLength = buf_size; ret = InternetReadFileExW(req, buf, flags, 0xdeadbeef); ok_(__FILE__,line)(!ret && GetLastError() == ERROR_IO_PENDING, "InternetReadFileExW returned %x (%u)\n", ret, GetLastError()); @@ -5212,10 +5287,6 @@ if(!is_ie7plus) return; - hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); - conn_wait_event = CreateEventW(NULL, FALSE, FALSE, NULL); - server_req_rec_event = CreateEventW(NULL, FALSE, FALSE, NULL); - memset(&ib, 0, sizeof(ib)); ib.dwStructSize = sizeof(ib); ib.lpvBuffer = buf; @@ -5237,7 +5308,7 @@ readex_expect_async(req.request, IRF_ASYNC, &ib, sizeof(buf), "0"); send_response_ex_and_wait("123", TRUE, &ib, "0123", 0, 4); - close_async_handle(req.session, hCompleteEvent, 2); + close_async_handle(req.session, 2); trace("Testing InternetReadFileExW with no flags...\n"); @@ -5256,7 +5327,7 @@ readex_expect_async(req.request, 0, &ib, sizeof(buf), "0"); send_response_ex_and_wait("123", TRUE, &ib, "0123", 0, 4); - close_async_handle(req.session, hCompleteEvent, 2); + close_async_handle(req.session, 2); trace("Testing InternetReadFile...\n"); @@ -5275,7 +5346,7 @@ read_expect_async(req.request, buf, sizeof(buf), &read_size, "0"); send_response_and_wait("123", TRUE, buf, &read_size, "0123", 4, 0, 4); - close_async_handle(req.session, hCompleteEvent, 2); + close_async_handle(req.session, 2); trace("Testing InternetReadFileExW with IRF_NO_WAIT flag...\n"); @@ -5306,7 +5377,7 @@ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "12345", 0); readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "", TRUE); - close_async_handle(req.session, hCompleteEvent, 2); + close_async_handle(req.session, 2); open_read_test_request(port, &req, "HTTP/1.1 200 OK\r\n" @@ -5333,7 +5404,7 @@ readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "x", 0); readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "", 0); - close_async_handle(req.session, hCompleteEvent, 2); + close_async_handle(req.session, 2); open_read_test_request(port, &req, "HTTP/1.1 200 OK\r\n" @@ -5347,7 +5418,7 @@ send_response_ex_and_wait("0\r\n\r\n", TRUE, &ib, NULL, 0, 5); readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "", 0); - close_async_handle(req.session, hCompleteEvent, 2); + close_async_handle(req.session, 2); open_read_test_request(port, &req, "HTTP/1.1 200 OK\r\n" @@ -5360,7 +5431,7 @@ SET_EXPECT(INTERNET_STATUS_CLOSING_CONNECTION); SET_EXPECT(INTERNET_STATUS_CONNECTION_CLOSED); - close_async_handle(req.session, hCompleteEvent, 2); + close_async_handle(req.session, 2); CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); @@ -5381,7 +5452,7 @@ SET_WINE_ALLOW(INTERNET_STATUS_CLOSING_CONNECTION); SET_WINE_ALLOW(INTERNET_STATUS_CONNECTION_CLOSED); - close_async_handle(req.session, hCompleteEvent, 2); + close_async_handle(req.session, 2); todo_wine CHECK_NOT_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); todo_wine CHECK_NOT_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); @@ -5419,11 +5490,7 @@ CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); - close_async_handle(req.session, hCompleteEvent, 2); - - CloseHandle(hCompleteEvent); - CloseHandle(conn_wait_event); - CloseHandle(server_req_rec_event); + close_async_handle(req.session, 2); skip_receive_notification_tests = FALSE; } @@ -5436,10 +5503,6 @@ if(!is_ie7plus) return; - - hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); - conn_wait_event = CreateEventW(NULL, FALSE, FALSE, NULL); - server_req_rec_event = CreateEventW(NULL, FALSE, FALSE, NULL); memset(&ib, 0, sizeof(ib)); ib.dwStructSize = sizeof(ib); @@ -5458,7 +5521,7 @@ close_connection(); SET_EXPECT(INTERNET_STATUS_CLOSING_CONNECTION); SET_EXPECT(INTERNET_STATUS_CONNECTION_CLOSED); - close_async_handle(req.session, hCompleteEvent, 2); + close_async_handle(req.session, 2); CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); } @@ -5497,6 +5560,230 @@ close_request(&req); } +static void test_persistent_connection(int port) +{ + INTERNET_BUFFERSW ib; + test_request_t req; + char buf[24000]; + + if(!is_ie7plus) + return; + + memset(&ib, 0, sizeof(ib)); + ib.dwStructSize = sizeof(ib); + ib.lpvBuffer = buf; + + skip_receive_notification_tests = TRUE; + + trace("Testing persistent connection...\n"); + + open_read_test_request(port, &req, + "HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "Content-Length: 2\r\n" + "\r\n" + "xx"); + readex_expect_sync_data(req.request, IRF_ASYNC, &ib, 4, "xx", 0); + close_async_handle(req.session, 2); + + open_socket_request(port, &req, "/test_simple_chunked"); + server_read_request("GET /test_simple_chunked HTTP/1.1"); + + SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); + server_send_string("HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "2\r\nab\r\n"); + WaitForSingleObject(complete_event, INFINITE); + CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); + ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error); + + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab", 0); + readex_expect_async(req.request, IRF_ASYNC, &ib, sizeof(buf), NULL); + send_response_ex_and_wait("3\r\nabc\r\n0\r\n\r\n", FALSE, &ib, "abc", 0, 13); + close_async_handle(req.session, 2); + + open_socket_request(port, &req, "/chunked"); + server_read_request("GET /chunked HTTP/1.1"); + + SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); + server_send_string("HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "2\r\nab\r\n"); + WaitForSingleObject(complete_event, INFINITE); + CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); + ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error); + + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, 3, "ab", 0); + readex_expect_async(req.request, IRF_ASYNC, &ib, 3, NULL); + send_response_ex_and_wait("3\r\nabc\r\n", FALSE, &ib, "abc", 0, 13); + + /* send another request on the same request handle, it must drain remaining last chunk marker */ + server_send_string("0\r\n\r\n"); + + send_socket_request(&req, FALSE); + server_read_request("GET /chunked HTTP/1.1"); + + ResetEvent(complete_event); + SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); + server_send_string("HTTP/1.1 201 OK\r\n" + "Server: winetest\r\n" + "Content-Length: 0\r\n" + "Connection: keep-alive\r\n" + "\r\n"); + WaitForSingleObject(complete_event, INFINITE); + CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); + ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error); + + test_status_code(req.request, 201); + close_async_handle(req.session, 2); + + /* the connection is still valid */ + open_socket_request(port, &req, "/another_chunked"); + server_read_request("GET /another_chunked HTTP/1.1"); + + SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); + server_send_string("HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "Transfer-Encoding: chunked\r\n" + "\r\n" + "2\r\nab\r\n"); + WaitForSingleObject(complete_event, INFINITE); + CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); + ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error); + + readex_expect_sync_data(req.request, IRF_NO_WAIT, &ib, sizeof(buf), "ab", 0); + readex_expect_async(req.request, IRF_ASYNC, &ib, sizeof(buf), NULL); + + /* we're missing trailing '\n'; the connection can't be drained without blocking, + * so it will be closed */ + send_response_ex_and_wait("3\r\nabc\r\n0\r\n\r", FALSE, &ib, "abc", 0, 13); + + SET_EXPECT(INTERNET_STATUS_CLOSING_CONNECTION); + SET_EXPECT(INTERNET_STATUS_CONNECTION_CLOSED); + close_async_handle(req.session, 2); + CHECK_NOTIFIED(INTERNET_STATUS_CLOSING_CONNECTION); + CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED); + + close_connection(); + skip_receive_notification_tests = FALSE; +} + +static void test_redirect(int port) +{ + char buf[4000], expect_url[INTERNET_MAX_URL_LENGTH]; + INTERNET_BUFFERSW ib; + test_request_t req; + + if(!is_ie7plus) + return; + + skip_receive_notification_tests = TRUE; + + memset(&ib, 0, sizeof(ib)); + ib.dwStructSize = sizeof(ib); + ib.lpvBuffer = buf; + + trace("Testing redirection...\n"); + + open_socket_request(port, &req, NULL); + + SET_OPTIONAL(INTERNET_STATUS_COOKIE_SENT); + SET_EXPECT(INTERNET_STATUS_REDIRECT); + SET_EXPECT(INTERNET_STATUS_SENDING_REQUEST); + SET_EXPECT(INTERNET_STATUS_REQUEST_SENT); + + server_send_string("HTTP/1.1 302 Found\r\n" + "Server: winetest\r\n" + "Location: test_redirection\r\n" + "Connection: keep-alive\r\n" + "Content-Length: 0\r\n" + "\r\n"); + + server_read_request("GET /test_redirection HTTP/1.1"); + + CHECK_NOTIFIED(INTERNET_STATUS_SENDING_REQUEST); + + sprintf(expect_url, "
http://localhost:%u/test_redirection
", port); + test_request_url(req.request, expect_url); + + SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); + + server_send_string("HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "Content-Length: 3\r\n" + "\r\n" + "xxx"); + + WaitForSingleObject(complete_event, INFINITE); + + CLEAR_NOTIFIED(INTERNET_STATUS_COOKIE_SENT); + CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_SENT); + CHECK_NOTIFIED(INTERNET_STATUS_REDIRECT); + CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); + ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error); + + test_status_code(req.request, 200); + + close_connection(); + close_async_handle(req.session, 2); + + trace("Test redirect to non-http URL...\n"); + + open_socket_request(port, &req, NULL); + + SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); + + server_send_string("HTTP/1.1 302 Found\r\n" + "Server: winetest\r\n" + "Location: test:non:http/url\r\n" + "Connection: keep-alive\r\n" + "Content-Length: 0\r\n" + "\r\n"); + + WaitForSingleObject(complete_event, INFINITE); + + CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); + ok(req_error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", req_error); + + sprintf(expect_url, "
http://localhost:%u/socket
", port); + test_request_url(req.request, expect_url); + test_status_code(req.request, 302); + + close_connection(); + close_async_handle(req.session, 2); + + trace("Test redirect to http URL with no host name...\n"); + + open_socket_request(port, &req, NULL); + + SET_EXPECT(INTERNET_STATUS_REQUEST_COMPLETE); + + server_send_string("HTTP/1.1 302 Found\r\n" + "Server: winetest\r\n" + "Location: http:///nohost\r\n" + "Connection: keep-alive\r\n" + "Content-Length: 0\r\n" + "\r\n"); + + WaitForSingleObject(complete_event, INFINITE); + + CHECK_NOTIFIED(INTERNET_STATUS_REQUEST_COMPLETE); + ok(req_error == ERROR_INTERNET_INVALID_URL, "expected ERROR_INTERNET_INVALID_URL, got %u\n", req_error); + + sprintf(expect_url, "
http://localhost:%u/socket
", port); + test_request_url(req.request, expect_url); + test_status_code(req.request, 302); + + close_connection(); + close_async_handle(req.session, 2); + + skip_receive_notification_tests = FALSE; +} + static void test_remove_dot_segments(int port) { test_request_t req; @@ -5511,7 +5798,7 @@ close_request(&req); } -static void test_redirect(int port) +static void test_redirect_no_host(int port) { test_request_t req; BOOL ret; @@ -5584,8 +5871,10 @@ test_http_read(si.port); test_connection_break(si.port); test_long_url(si.port); + test_redirect(si.port); + test_persistent_connection(si.port); test_remove_dot_segments(si.port); - test_redirect(si.port); + test_redirect_no_host(si.port); /* send the basic request again to shutdown the server thread */ test_basic_request(si.port, "GET", "/quit"); @@ -5723,8 +6012,7 @@ BOOL res; trace("Testing security flags...\n"); - - hCompleteEvent = CreateEventW(NULL, FALSE, FALSE, NULL); + reset_events(); ses = InternetOpenA("WineTest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_ASYNC); ok(ses != NULL, "InternetOpen failed\n"); @@ -5750,8 +6038,7 @@ if(!res && GetLastError() == ERROR_INVALID_PARAMETER) { win_skip("Incomplete security flags support, skipping\n"); - close_async_handle(ses, hCompleteEvent, 2); - CloseHandle(hCompleteEvent); + close_async_handle(ses, 2); return; } @@ -5790,7 +6077,7 @@ res = HttpSendRequestA(req, NULL, 0, NULL, 0); ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError()); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); ok(req_error == ERROR_SUCCESS, "req_error = %d\n", req_error); CHECK_NOTIFIED(INTERNET_STATUS_RESOLVING_NAME); @@ -5845,7 +6132,7 @@ res = HttpSendRequestA(req, NULL, 0, NULL, 0); ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError()); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); ok(req_error == ERROR_INTERNET_SEC_CERT_REV_FAILED || broken(req_error == ERROR_INTERNET_SEC_CERT_ERRORS), "req_error = %d\n", req_error); @@ -5884,8 +6171,7 @@ if(req_error != ERROR_INTERNET_SEC_CERT_REV_FAILED) { win_skip("Unexpected cert errors %u, skipping security flags tests\n", req_error); - close_async_handle(ses, hCompleteEvent, 3); - CloseHandle(hCompleteEvent); + close_async_handle(ses, 3); return; } @@ -5912,7 +6198,7 @@ res = HttpSendRequestA(req, NULL, 0, NULL, 0); ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError()); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); ok(req_error == ERROR_INTERNET_SEC_CERT_ERRORS, "req_error = %d\n", req_error); CHECK_NOTIFIED(INTERNET_STATUS_CONNECTING_TO_SERVER); @@ -5949,7 +6235,7 @@ res = HttpSendRequestA(req, NULL, 0, NULL, 0); ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError()); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); ok(req_error == ERROR_SUCCESS, "req_error = %d\n", req_error); CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTING_TO_SERVER, 2); @@ -5976,7 +6262,7 @@ ok(res, "InternetReadFile failed: %u\n", GetLastError()); ok(size, "size = 0\n"); - close_async_handle(ses, hCompleteEvent, 3); + close_async_handle(ses, 3); /* Collect all existing persistent connections */ res = InternetSetOptionA(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0); @@ -6022,7 +6308,7 @@ res = HttpSendRequestA(req, NULL, 0, NULL, 0); ok(!res && GetLastError() == ERROR_IO_PENDING, "HttpSendRequest failed: %u\n", GetLastError()); - WaitForSingleObject(hCompleteEvent, INFINITE); + WaitForSingleObject(complete_event, INFINITE); ok(req_error == ERROR_SUCCESS, "req_error = %d\n", req_error); CHECK_NOTIFIED2(INTERNET_STATUS_CONNECTING_TO_SERVER, 2); @@ -6044,9 +6330,7 @@ ok(res, "InternetReadFile failed: %u\n", GetLastError()); ok(size, "size = 0\n"); - close_async_handle(ses, hCompleteEvent, 2); - - CloseHandle(hCompleteEvent); + close_async_handle(ses, 2); test_security_info("
http://test.winehq.com/data/some_file.html?q
", ERROR_INTERNET_ITEM_NOT_FOUND, 0); test_security_info("file:///c:/dir/file.txt", ERROR_INTERNET_ITEM_NOT_FOUND, 0); @@ -6311,7 +6595,8 @@ INTERNET_ASYNC_RESULT *result = info; struct context *ctx = (struct context *)context; - trace("%p 0x%08lx %u %p 0x%08x\n", handle, context, status, info, size); + if(winetest_debug > 1) + trace("%p 0x%08lx %u %p 0x%08x\n", handle, context, status, info, size); switch(status) { case INTERNET_STATUS_REQUEST_COMPLETE: @@ -6759,7 +7044,8 @@ DWORD len, type; BOOL res; - trace("closetest_callback %p: %d\n", hInternet, dwInternetStatus); + if(winetest_debug > 1) + trace("closetest_callback %p: %d\n", hInternet, dwInternetStatus); ok(hInternet == closetest_session || hInternet == closetest_conn || hInternet == closetest_req, "Unexpected hInternet %p\n", hInternet); @@ -6812,7 +7098,7 @@ len = sizeof(flags); res = InternetQueryOptionA(closetest_req, INTERNET_OPTION_REQUEST_FLAGS, &flags, &len); ok(!res && GetLastError() == ERROR_INVALID_HANDLE, - "InternetQueryOptionA(%p INTERNET_OPTION_URL) failed: %x %u, expected TRUE ERROR_INVALID_HANDLE\n", + "InternetQueryOptionA(%p INTERNET_OPTION_REQUEST_FLAGS) failed: %x %u, expected TRUE ERROR_INVALID_HANDLE\n", closetest_req, res, GetLastError()); } @@ -7024,6 +7310,7 @@ win_skip("IE6 found. It's too old for some tests.\n"); } + init_events(); init_status_tests(); test_InternetCloseHandle(); InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[0]); @@ -7053,4 +7340,5 @@ test_connection_failure(); test_default_service_port(); test_concurrent_header_access(); -} + free_events(); +}
7 years, 3 months
1
0
0
0
[akhaldi] 75946: [WININET] Sync with Wine Staging 2.16. CORE-13762 43deec9 wininet: Use standard wine_dbgstr_longlong. 085ce26 wininet: Drain content before reusing connection in open_http_connecti...
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:17:59 2017 New Revision: 75946 URL:
http://svn.reactos.org/svn/reactos?rev=75946&view=rev
Log: [WININET] Sync with Wine Staging 2.16. CORE-13762 43deec9 wininet: Use standard wine_dbgstr_longlong. 085ce26 wininet: Drain content before reusing connection in open_http_connection. 59395d8 wininet: Never do blocking reads in chunked_read if zero chunk size is aready read. 4f40039 wininet: Release connection in HTTPREQ_Read only if remaining control data may be drainad without blocking. 8090d16 wininet: Store error state separately from end of stream in chunked stream. 752d078 wininet: Always use drain_content specific to stream type. 90b936f wininet: Try to read reamaining data in chunked_drain_content. 2ecdac8 wininet: Return error codes from HTTP streams. 7949a22 wininet: Correctly pass URL length to InternetCrackUrlW in get_redirect_url. a24b826 wininet: Improved cookie debug traces. f55a116 wininet: Fix potential use-after-free (Coverity). 89f1d8c wininet: Fixed connection_pool_cs declaration. cee9982 wininet: Return an error on redirect with no host name specified. 61e28c0 wininet: Moved INTERNET_STATUS_REDIRECT notification to HTTP_HandleRedirect. 9c95915 wininet: Correctly handle redirects to non-http URLs. Modified: trunk/reactos/dll/win32/wininet/cookie.c trunk/reactos/dll/win32/wininet/http.c trunk/reactos/dll/win32/wininet/urlcache.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/wininet/cookie.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/cookie.c…
============================================================================== --- trunk/reactos/dll/win32/wininet/cookie.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/cookie.c [iso-8859-1] Sun Sep 24 11:17:59 2017 @@ -544,17 +544,11 @@ } for(domain = get_cookie_domain(host, FALSE); domain; domain = domain->parent) { - TRACE("Trying %s domain...\n", debugstr_w(domain->domain)); - LIST_FOR_EACH_ENTRY(container, &domain->path_list, cookie_container_t, entry) { struct list *cursor, *cursor2; - TRACE("path %s\n", debugstr_wn(container->path.str, container->path.len)); - if(!cookie_match_path(container, path)) continue; - - TRACE("found domain %p\n", domain->domain); LIST_FOR_EACH_SAFE(cursor, cursor2, &container->cookie_list) { cookie_t *cookie_iter = LIST_ENTRY(cursor, cookie_t, entry); @@ -569,7 +563,6 @@ if((cookie_iter->flags & INTERNET_COOKIE_HTTPONLY) && !(flags & INTERNET_COOKIE_HTTPONLY)) continue; - if(!res->size) { res->cookies = heap_alloc(4*sizeof(*res->cookies)); @@ -584,6 +577,9 @@ res->size *= 2; } + TRACE("%s = %s domain %s path %s\n", debugstr_w(cookie_iter->name), debugstr_w(cookie_iter->data), + debugstr_w(domain->domain), debugstr_wn(container->path.str, container->path.len)); + if(res->cnt) res->string_len += 2; /* '; ' */ res->cookies[res->cnt++] = cookie_iter; Modified: trunk/reactos/dll/win32/wininet/http.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/http.c?r…
============================================================================== --- trunk/reactos/dll/win32/wininet/http.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/http.c [iso-8859-1] Sun Sep 24 11:17:59 2017 @@ -180,13 +180,13 @@ static LPWSTR HTTP_build_req( LPCWSTR *list, int len ); static DWORD HTTP_HttpQueryInfoW(http_request_t*, DWORD, LPVOID, LPDWORD, LPDWORD); static UINT HTTP_DecodeBase64(LPCWSTR base64, LPSTR bin); -static BOOL drain_content(http_request_t*,BOOL); +static DWORD drain_content(http_request_t*,BOOL); static CRITICAL_SECTION connection_pool_cs; static CRITICAL_SECTION_DEBUG connection_pool_debug = { 0, 0, &connection_pool_cs, - { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList }, + { &connection_pool_debug.ProcessLocksList, &connection_pool_debug.ProcessLocksList }, 0, 0, { (DWORD_PTR)(__FILE__ ": connection_pool_cs") } }; static CRITICAL_SECTION connection_pool_cs = { &connection_pool_debug, -1, 0, 0, 0, 0 }; @@ -367,7 +367,7 @@ struct data_stream_vtbl_t { BOOL (*end_of_data)(data_stream_t*,http_request_t*); DWORD (*read)(data_stream_t*,http_request_t*,BYTE*,DWORD,DWORD*,BOOL); - BOOL (*drain_content)(data_stream_t*,http_request_t*); + DWORD (*drain_content)(data_stream_t*,http_request_t*,BOOL); void (*destroy)(data_stream_t*); }; @@ -385,7 +385,8 @@ CHUNKED_STREAM_STATE_READING_CHUNK, CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_DATA, CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END, - CHUNKED_STREAM_STATE_END_OF_STREAM + CHUNKED_STREAM_STATE_END_OF_STREAM, + CHUNKED_STREAM_STATE_ERROR } state; } chunked_stream_t; @@ -493,10 +494,10 @@ return res; } -static BOOL gzip_drain_content(data_stream_t *stream, http_request_t *req) +static DWORD gzip_drain_content(data_stream_t *stream, http_request_t *req, BOOL allow_blocking) { gzip_stream_t *gzip_stream = (gzip_stream_t*)stream; - return gzip_stream->parent_stream->vtbl->drain_content(gzip_stream->parent_stream, req); + return gzip_stream->parent_stream->vtbl->drain_content(gzip_stream->parent_stream, req, allow_blocking); } static void gzip_destroy(data_stream_t *stream) @@ -2005,7 +2006,7 @@ { http_request_t *req = (http_request_t*)hdr; - http_release_netconn(req, drain_content(req, FALSE)); + http_release_netconn(req, drain_content(req, FALSE) == ERROR_SUCCESS); } static DWORD str_to_buffer(const WCHAR *str, void *buffer, DWORD *size, BOOL unicode) @@ -2628,7 +2629,7 @@ return res; } -static BOOL netconn_drain_content(data_stream_t *stream, http_request_t *req) +static DWORD netconn_drain_content(data_stream_t *stream, http_request_t *req, BOOL allow_blocking) { netconn_stream_t *netconn_stream = (netconn_stream_t*)stream; BYTE buf[1024]; @@ -2636,18 +2637,20 @@ size_t size; if(netconn_stream->content_length == ~0u) - return FALSE; + return WSAEISCONN; while(netconn_stream->content_read < netconn_stream->content_length) { size = min(sizeof(buf), netconn_stream->content_length-netconn_stream->content_read); - res = NETCON_recv(req->netconn, buf, size, FALSE, &len); - if(res || !len) - return FALSE; + res = NETCON_recv(req->netconn, buf, size, allow_blocking, &len); + if(res) + return res; + if(!len) + return WSAECONNABORTED; netconn_stream->content_read += len; } - return TRUE; + return ERROR_SUCCESS; } static void netconn_destroy(data_stream_t *stream) @@ -2672,7 +2675,14 @@ static BOOL chunked_end_of_data(data_stream_t *stream, http_request_t *req) { chunked_stream_t *chunked_stream = (chunked_stream_t*)stream; - return chunked_stream->state == CHUNKED_STREAM_STATE_END_OF_STREAM; + switch(chunked_stream->state) { + case CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END: + case CHUNKED_STREAM_STATE_END_OF_STREAM: + case CHUNKED_STREAM_STATE_ERROR: + return TRUE; + default: + return FALSE; + } } static DWORD chunked_read(data_stream_t *stream, http_request_t *req, BYTE *buf, DWORD size, @@ -2689,22 +2699,28 @@ /* Ensure that we have data in the buffer for states that need it. */ if(!chunked_stream->buf_size) { + BOOL blocking_read = allow_blocking; + switch(chunked_stream->state) { + case CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END: + case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_SIZE: + /* never allow blocking after 0 chunk size */ + if(!chunked_stream->chunk_size) + blocking_read = FALSE; + /* fall through */ case CHUNKED_STREAM_STATE_READING_CHUNK_SIZE: - case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_SIZE: case CHUNKED_STREAM_STATE_DISCARD_EOL_AFTER_DATA: - case CHUNKED_STREAM_STATE_DISCARD_EOL_AT_END: chunked_stream->buf_pos = 0; - res = NETCON_recv(req->netconn, chunked_stream->buf, sizeof(chunked_stream->buf), allow_blocking, &read_bytes); + res = NETCON_recv(req->netconn, chunked_stream->buf, sizeof(chunked_stream->buf), blocking_read, &read_bytes); if(res == ERROR_SUCCESS && read_bytes) { chunked_stream->buf_size += read_bytes; }else if(res == WSAEWOULDBLOCK) { - if(ret_read) + if(ret_read || allow_blocking) res = ERROR_SUCCESS; continue_read = FALSE; continue; }else { - chunked_stream->state = CHUNKED_STREAM_STATE_END_OF_STREAM; + chunked_stream->state = CHUNKED_STREAM_STATE_ERROR; } break; default: @@ -2766,7 +2782,7 @@ } if(!read_bytes) { - chunked_stream->state = CHUNKED_STREAM_STATE_END_OF_STREAM; + chunked_stream->state = CHUNKED_STREAM_STATE_ERROR; continue; } } @@ -2796,6 +2812,7 @@ break; case CHUNKED_STREAM_STATE_END_OF_STREAM: + case CHUNKED_STREAM_STATE_ERROR: continue_read = FALSE; break; } @@ -2811,10 +2828,22 @@ return ERROR_SUCCESS; } -static BOOL chunked_drain_content(data_stream_t *stream, http_request_t *req) +static DWORD chunked_drain_content(data_stream_t *stream, http_request_t *req, BOOL allow_blocking) { chunked_stream_t *chunked_stream = (chunked_stream_t*)stream; - return chunked_stream->state == CHUNKED_STREAM_STATE_END_OF_STREAM; + BYTE buf[1024]; + DWORD size, res; + + while(chunked_stream->state != CHUNKED_STREAM_STATE_END_OF_STREAM + && chunked_stream->state != CHUNKED_STREAM_STATE_ERROR) { + res = chunked_read(stream, req, buf, sizeof(buf), &size, allow_blocking); + if(res != ERROR_SUCCESS) + return res; + } + + if(chunked_stream->state != CHUNKED_STREAM_STATE_END_OF_STREAM) + return ERROR_NO_DATA; + return ERROR_SUCCESS; } static void chunked_destroy(data_stream_t *stream) @@ -2968,46 +2997,34 @@ LeaveCriticalSection( &req->read_section ); *read = ret_read; - TRACE( "retrieved %u bytes (%u)\n", ret_read, req->contentLength ); - - if(res != WSAEWOULDBLOCK && (!ret_read || res != ERROR_SUCCESS)) - http_release_netconn(req, res == ERROR_SUCCESS); + TRACE( "retrieved %u bytes (res %u)\n", ret_read, res ); + + if(res != WSAEWOULDBLOCK) { + if(res != ERROR_SUCCESS) + http_release_netconn(req, FALSE); + else if(!ret_read && drain_content(req, FALSE) == ERROR_SUCCESS) + http_release_netconn(req, TRUE); + } return res; } -static BOOL drain_content(http_request_t *req, BOOL blocking) -{ - BOOL ret; - - if(!is_valid_netconn(req->netconn) || req->contentLength == -1) - return FALSE; +static DWORD drain_content(http_request_t *req, BOOL blocking) +{ + DWORD res; + + TRACE("%p\n", req->netconn); + + if(!is_valid_netconn(req->netconn)) + return ERROR_NO_DATA; if(!strcmpW(req->verb, szHEAD)) - return TRUE; - - if(!blocking) - return req->data_stream->vtbl->drain_content(req->data_stream, req); + return ERROR_SUCCESS; EnterCriticalSection( &req->read_section ); - - while(1) { - DWORD bytes_read, res; - BYTE buf[4096]; - - res = HTTPREQ_Read(req, buf, sizeof(buf), &bytes_read, TRUE); - if(res != ERROR_SUCCESS) { - ret = FALSE; - break; - } - if(!bytes_read) { - ret = TRUE; - break; - } - } - + res = req->data_stream->vtbl->drain_content(req->data_stream, req, blocking); LeaveCriticalSection( &req->read_section ); - return ret; + return res; } typedef struct { @@ -3042,7 +3059,7 @@ if(task->ret_read) complete_arg = read; /* QueryDataAvailable reports read bytes in request complete notification */ if(res != ERROR_SUCCESS || !read) - http_release_netconn(req, drain_content(req, FALSE)); + http_release_netconn(req, drain_content(req, FALSE) == ERROR_SUCCESS); } TRACE("res %u read %u\n", res, read); @@ -3987,7 +4004,16 @@ return NULL; } + urlComponents.dwSchemeLength = 1; + b = InternetCrackUrlW(redirect_url, url_length / sizeof(WCHAR), 0, &urlComponents); + if(b && urlComponents.dwSchemeLength && + urlComponents.nScheme != INTERNET_SCHEME_HTTP && urlComponents.nScheme != INTERNET_SCHEME_HTTPS) { + TRACE("redirect to non-http URL\n"); + return NULL; + } + urlComponents.lpszScheme = (request->hdr.dwFlags & INTERNET_FLAG_SECURE) ? szHttps : szHttp; + urlComponents.dwSchemeLength = 0; urlComponents.lpszHostName = request->server->name; urlComponents.nPort = request->server->port; urlComponents.lpszUserName = session->userName; @@ -4024,30 +4050,36 @@ /*********************************************************************** * HTTP_HandleRedirect (internal) */ -static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl) -{ +static DWORD HTTP_HandleRedirect(http_request_t *request, WCHAR *url) +{ + URL_COMPONENTSW urlComponents = { sizeof(urlComponents) }; http_session_t *session = request->session; - WCHAR *path; - - if(lpszUrl[0]=='/') + size_t url_len = strlenW(url); + + if(url[0] == '/') { /* if it's an absolute path, keep the same session info */ - path = heap_strdupW(lpszUrl); + urlComponents.lpszUrlPath = url; + urlComponents.dwUrlPathLength = url_len; } else { - URL_COMPONENTSW urlComponents = { sizeof(urlComponents) }; - BOOL custom_port = FALSE; - substr_t host; - urlComponents.dwHostNameLength = 1; urlComponents.dwUserNameLength = 1; urlComponents.dwUrlPathLength = 1; - if(!InternetCrackUrlW(lpszUrl, strlenW(lpszUrl), 0, &urlComponents)) + if(!InternetCrackUrlW(url, url_len, 0, &urlComponents)) return INTERNET_GetLastError(); - if (!urlComponents.dwHostNameLength) + if(!urlComponents.dwHostNameLength) return ERROR_INTERNET_INVALID_URL; + } + + INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, INTERNET_STATUS_REDIRECT, + url, (url_len + 1) * sizeof(WCHAR)); + + if(urlComponents.dwHostNameLength) { + BOOL custom_port = FALSE; + substr_t host; if(urlComponents.nScheme == INTERNET_SCHEME_HTTP) { if(request->hdr.dwFlags & INTERNET_FLAG_SECURE) { @@ -4094,17 +4126,18 @@ HTTP_ProcessHeader(request, hostW, request->server->host_port, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); else HTTP_ProcessHeader(request, hostW, request->server->name, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); - - path = heap_strndupW(urlComponents.lpszUrlPath, urlComponents.dwUrlPathLength); - } + } + heap_free(request->path); request->path = NULL; - if (*path) + if(urlComponents.dwUrlPathLength) { DWORD needed = 1; HRESULT rc; WCHAR dummy = 0; - + WCHAR *path; + + path = heap_strndupW(urlComponents.lpszUrlPath, urlComponents.dwUrlPathLength); rc = UrlEscapeW(path, &dummy, &needed, URL_ESCAPE_SPACES_ONLY); if (rc != E_POINTER) ERR("Unable to escape string!(%s) (%d)\n",debugstr_w(path),rc); @@ -4116,9 +4149,8 @@ ERR("Unable to escape string!(%s) (%d)\n",debugstr_w(path),rc); strcpyW(request->path, path); } - } - - heap_free(path); + heap_free(path); + } /* Remove custom content-type/length headers on redirects. */ remove_header(request, szContent_Type, TRUE); @@ -4707,21 +4739,21 @@ netconn_t *netconn = NULL; DWORD res; - reset_data_stream(request); - if (request->netconn) { - if (is_valid_netconn(request->netconn) && NETCON_is_alive(request->netconn)) - { + if (NETCON_is_alive(request->netconn) && drain_content(request, TRUE) == ERROR_SUCCESS) + { + reset_data_stream(request); *reusing = TRUE; return ERROR_SUCCESS; } - else - { - free_netconn(request->netconn); - request->netconn = NULL; - } - } + + TRACE("freeing netconn\n"); + free_netconn(request->netconn); + request->netconn = NULL; + } + + reset_data_stream(request); res = HTTP_ResolveName(request); if(res != ERROR_SUCCESS) @@ -5027,9 +5059,7 @@ heap_free(request->verb); request->verb = heap_strdupW(szGET); } - http_release_netconn(request, drain_content(request, FALSE)); - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, INTERNET_STATUS_REDIRECT, - new_url, (strlenW(new_url) + 1) * sizeof(WCHAR)); + http_release_netconn(request, drain_content(request, FALSE) == ERROR_SUCCESS); res = HTTP_HandleRedirect(request, new_url); heap_free(new_url); if (res == ERROR_SUCCESS) { @@ -5055,7 +5085,7 @@ request->session->password, host)) { heap_free(requestString); - if(!drain_content(request, TRUE)) { + if(!drain_content(request, TRUE) == ERROR_SUCCESS) { FIXME("Could not drain content\n"); http_release_netconn(request, FALSE); } @@ -5083,7 +5113,7 @@ NULL)) { heap_free(requestString); - if(!drain_content(request, TRUE)) { + if(!drain_content(request, TRUE) == ERROR_SUCCESS) { FIXME("Could not drain content\n"); http_release_netconn(request, FALSE); } @@ -5225,9 +5255,7 @@ heap_free(request->verb); request->verb = heap_strdupW(szGET); } - http_release_netconn(request, drain_content(request, FALSE)); - INTERNET_SendCallback(&request->hdr, request->hdr.dwContext, INTERNET_STATUS_REDIRECT, - new_url, (strlenW(new_url) + 1) * sizeof(WCHAR)); + http_release_netconn(request, drain_content(request, FALSE) == ERROR_SUCCESS); res = HTTP_HandleRedirect(request, new_url); heap_free(new_url); if (res == ERROR_SUCCESS) Modified: trunk/reactos/dll/win32/wininet/urlcache.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wininet/urlcache…
============================================================================== --- trunk/reactos/dll/win32/wininet/urlcache.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wininet/urlcache.c [iso-8859-1] Sun Sep 24 11:17:59 2017 @@ -3424,8 +3424,8 @@ LPVOID lpReserved3 ) { - FIXME("(%s, 0x%08x, 0x%08x, 0x%08x%08x, %p, %p, %p, %p, %p) stub\n", debugstr_a(lpszUrlSearchPattern), - dwFlags, dwFilter, (ULONG)(GroupId >> 32), (ULONG)GroupId, lpFirstCacheEntryInfo, + FIXME("(%s, 0x%08x, 0x%08x, 0x%s, %p, %p, %p, %p, %p) stub\n", debugstr_a(lpszUrlSearchPattern), + dwFlags, dwFilter, wine_dbgstr_longlong(GroupId), lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize, lpReserved, pcbReserved2,lpReserved3); SetLastError(ERROR_FILE_NOT_FOUND); return NULL; @@ -3443,8 +3443,8 @@ LPVOID lpReserved3 ) { - FIXME("(%s, 0x%08x, 0x%08x, 0x%08x%08x, %p, %p, %p, %p, %p) stub\n", debugstr_w(lpszUrlSearchPattern), - dwFlags, dwFilter, (ULONG)(GroupId >> 32), (ULONG)GroupId, lpFirstCacheEntryInfo, + FIXME("(%s, 0x%08x, 0x%08x, 0x%s, %p, %p, %p, %p, %p) stub\n", debugstr_w(lpszUrlSearchPattern), + dwFlags, dwFilter, wine_dbgstr_longlong(GroupId), lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize, lpReserved, pcbReserved2,lpReserved3); SetLastError(ERROR_FILE_NOT_FOUND); return NULL; @@ -3720,8 +3720,8 @@ */ BOOL WINAPI DeleteUrlCacheGroup(GROUPID GroupId, DWORD dwFlags, LPVOID lpReserved) { - FIXME("(0x%08x%08x, 0x%08x, %p) stub\n", - (ULONG)(GroupId >> 32), (ULONG)GroupId, dwFlags, lpReserved); + FIXME("(0x%s, 0x%08x, %p) stub\n", + wine_dbgstr_longlong(GroupId), dwFlags, lpReserved); return FALSE; } @@ -3743,8 +3743,8 @@ GROUPID GroupId, LPBYTE pbGroupAttributes, DWORD cbGroupAttributes, LPVOID lpReserved) { - FIXME("(%s, 0x%08x, 0x%08x%08x, %p, 0x%08x, %p) stub\n", - debugstr_a(lpszUrlName), dwFlags, (ULONG)(GroupId >> 32), (ULONG)GroupId, + FIXME("(%s, 0x%08x, 0x%s, %p, 0x%08x, %p) stub\n", + debugstr_a(lpszUrlName), dwFlags, wine_dbgstr_longlong(GroupId), pbGroupAttributes, cbGroupAttributes, lpReserved); SetLastError(ERROR_FILE_NOT_FOUND); return FALSE; @@ -3758,8 +3758,8 @@ GROUPID GroupId, LPBYTE pbGroupAttributes, DWORD cbGroupAttributes, LPVOID lpReserved) { - FIXME("(%s, 0x%08x, 0x%08x%08x, %p, 0x%08x, %p) stub\n", - debugstr_w(lpszUrlName), dwFlags, (ULONG)(GroupId >> 32), (ULONG)GroupId, + FIXME("(%s, 0x%08x, 0x%s, %p, 0x%08x, %p) stub\n", + debugstr_w(lpszUrlName), dwFlags, wine_dbgstr_longlong(GroupId), pbGroupAttributes, cbGroupAttributes, lpReserved); SetLastError(ERROR_FILE_NOT_FOUND); return FALSE; @@ -3789,8 +3789,8 @@ LPINTERNET_CACHE_GROUP_INFOA lpGroupInfo, LPDWORD lpdwGroupInfo, LPVOID lpReserved ) { - FIXME("(0x%08x%08x, 0x%08x, 0x%08x, %p, %p, %p) stub\n", - (ULONG)(gid >> 32), (ULONG)gid, dwFlags, dwAttributes, lpGroupInfo, + FIXME("(0x%s, 0x%08x, 0x%08x, %p, %p, %p) stub\n", + wine_dbgstr_longlong(gid), dwFlags, dwAttributes, lpGroupInfo, lpdwGroupInfo, lpReserved); return FALSE; } @@ -3799,8 +3799,8 @@ LPINTERNET_CACHE_GROUP_INFOW lpGroupInfo, LPDWORD lpdwGroupInfo, LPVOID lpReserved ) { - FIXME("(0x%08x%08x, 0x%08x, 0x%08x, %p, %p, %p) stub\n", - (ULONG)(gid >> 32), (ULONG)gid, dwFlags, dwAttributes, lpGroupInfo, + FIXME("(0x%s, 0x%08x, 0x%08x, %p, %p, %p) stub\n", + wine_dbgstr_longlong(gid), dwFlags, dwAttributes, lpGroupInfo, lpdwGroupInfo, lpReserved); return FALSE; } @@ -3808,16 +3808,16 @@ BOOL WINAPI SetUrlCacheGroupAttributeA( GROUPID gid, DWORD dwFlags, DWORD dwAttributes, LPINTERNET_CACHE_GROUP_INFOA lpGroupInfo, LPVOID lpReserved ) { - FIXME("(0x%08x%08x, 0x%08x, 0x%08x, %p, %p) stub\n", - (ULONG)(gid >> 32), (ULONG)gid, dwFlags, dwAttributes, lpGroupInfo, lpReserved); + FIXME("(0x%s, 0x%08x, 0x%08x, %p, %p) stub\n", + wine_dbgstr_longlong(gid), dwFlags, dwAttributes, lpGroupInfo, lpReserved); return TRUE; } BOOL WINAPI SetUrlCacheGroupAttributeW( GROUPID gid, DWORD dwFlags, DWORD dwAttributes, LPINTERNET_CACHE_GROUP_INFOW lpGroupInfo, LPVOID lpReserved ) { - FIXME("(0x%08x%08x, 0x%08x, 0x%08x, %p, %p) stub\n", - (ULONG)(gid >> 32), (ULONG)gid, dwFlags, dwAttributes, lpGroupInfo, lpReserved); + FIXME("(0x%s, 0x%08x, 0x%08x, %p, %p) stub\n", + wine_dbgstr_longlong(gid), dwFlags, dwAttributes, lpGroupInfo, lpReserved); return TRUE; } Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Sep 24 11:17:59 2017 @@ -201,7 +201,7 @@ reactos/dll/win32/winemp3.acm # Synced to WineStaging-2.16 reactos/dll/win32/wing32 # Synced to WineStaging-2.9 reactos/dll/win32/winhttp # Synced to WineStaging-2.16 -reactos/dll/win32/wininet # Synced to WineStaging-2.9 +reactos/dll/win32/wininet # Synced to WineStaging-2.16 reactos/dll/win32/winmm # Forked at Wine-20050628 reactos/dll/win32/winmm/midimap # Forked at Wine-20050628 reactos/dll/win32/winmm/wavemap # Forked at Wine-20050628
7 years, 3 months
1
0
0
0
[akhaldi] 75945: [WINHTTP_WINETEST] Sync with Wine Staging 2.16. CORE-13762
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:17:51 2017 New Revision: 75945 URL:
http://svn.reactos.org/svn/reactos?rev=75945&view=rev
Log: [WINHTTP_WINETEST] Sync with Wine Staging 2.16. CORE-13762 Modified: trunk/rostests/winetests/winhttp/notification.c Modified: trunk/rostests/winetests/winhttp/notification.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/winhttp/notific…
============================================================================== --- trunk/rostests/winetests/winhttp/notification.c [iso-8859-1] (original) +++ trunk/rostests/winetests/winhttp/notification.c [iso-8859-1] Sun Sep 24 11:17:51 2017 @@ -22,12 +22,17 @@ #include <stdlib.h> #include <windef.h> #include <winbase.h> +#include <winsock2.h> +#include <ws2tcpip.h> #include <winhttp.h> #include "wine/test.h" static const WCHAR user_agent[] = {'w','i','n','e','t','e','s','t',0}; static const WCHAR test_winehq[] = {'t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0}; +static const WCHAR tests_hello_html[] = {'/','t','e','s','t','s','/','h','e','l','l','o','.','h','t','m','l',0}; +static const WCHAR tests_redirect[] = {'/','t','e','s','t','s','/','r','e','d','i','r','e','c','t',0}; +static const WCHAR localhostW[] = {'l','o','c','a','l','h','o','s','t',0}; enum api { @@ -45,10 +50,12 @@ { enum api function; /* api responsible for notification */ unsigned int status; /* status received */ - BOOL todo; - BOOL ignore; - BOOL skipped_for_proxy; -}; + DWORD flags; /* a combination of NF_* flags */ +}; + +#define NF_ALLOW 0x0001 /* notification may or may not happen */ +#define NF_WINE_ALLOW 0x0002 /* wine sends notification when it should not */ +#define NF_SIGNAL 0x0004 /* signal wait handle when notified */ struct info { @@ -60,62 +67,40 @@ unsigned int line; }; -static BOOL proxy_active(void) -{ - WINHTTP_PROXY_INFO proxy_info; - BOOL active = FALSE; - - if (WinHttpGetDefaultProxyConfiguration(&proxy_info)) - { - active = (proxy_info.lpszProxy != NULL); - if (active) - GlobalFree(proxy_info.lpszProxy); - if (proxy_info.lpszProxyBypass != NULL) - GlobalFree(proxy_info.lpszProxyBypass); - } - else - active = FALSE; - - return active; -} +struct test_request +{ + HINTERNET session; + HINTERNET connection; + HINTERNET request; +}; static void CALLBACK check_notification( HINTERNET handle, DWORD_PTR context, DWORD status, LPVOID buffer, DWORD buflen ) { BOOL status_ok, function_ok; struct info *info = (struct info *)context; - unsigned int i = info->index; if (status == WINHTTP_CALLBACK_STATUS_HANDLE_CREATED) { DWORD size = sizeof(struct info *); WinHttpQueryOption( handle, WINHTTP_OPTION_CONTEXT_VALUE, &info, &size ); } - ok(i < info->count, "%u: unexpected notification 0x%08x\n", info->line, status); - if (i >= info->count) return; - - status_ok = (info->test[i].status == status); - function_ok = (info->test[i].function == info->function); - if (!info->test[i].ignore && !info->test[i].todo) - { - ok(status_ok, "%u: expected status 0x%08x got 0x%08x\n", info->line, info->test[i].status, status); - ok(function_ok, "%u: expected function %u got %u\n", info->line, info->test[i].function, info->function); - } - else if (!info->test[i].ignore) - { - todo_wine ok(status_ok, "%u: expected status 0x%08x got 0x%08x\n", info->line, info->test[i].status, status); - if (status_ok) - { - todo_wine ok(function_ok, "%u: expected function %u got %u\n", info->line, info->test[i].function, info->function); - } - } - if (status_ok && function_ok) info->index++; - if (proxy_active()) - { - while (info->test[info->index].skipped_for_proxy) - info->index++; - } - - if (status & (WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS | WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING)) + while (info->index < info->count && info->test[info->index].status != status && (info->test[info->index].flags & NF_ALLOW)) + info->index++; + while (info->index < info->count && (info->test[info->index].flags & NF_WINE_ALLOW)) + { + todo_wine ok(info->test[info->index].status != status, "unexpected %x notification\n", status); + if (info->test[info->index].status == status) break; + info->index++; + } + ok(info->index < info->count, "%u: unexpected notification 0x%08x\n", info->line, status); + if (info->index >= info->count) return; + + status_ok = (info->test[info->index].status == status); + function_ok = (info->test[info->index].function == info->function); + ok(status_ok, "%u: expected status 0x%08x got 0x%08x\n", info->line, info->test[info->index].status, status); + ok(function_ok, "%u: expected function %u got %u\n", info->line, info->test[info->index].function, info->function); + + if (status_ok && function_ok && info->test[info->index++].flags & NF_SIGNAL) { SetEvent( info->wait ); } @@ -133,27 +118,65 @@ { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT }, { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE }, { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, FALSE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, FALSE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, FALSE, TRUE }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, NF_WINE_ALLOW }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, NF_WINE_ALLOW }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, NF_SIGNAL }, { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED }, - { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER }, - { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, NF_WINE_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, NF_WINE_ALLOW }, { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST }, { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT }, { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE }, { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, FALSE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, FALSE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, FALSE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE } + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, NF_WINE_ALLOW }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, NF_WINE_ALLOW }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, NF_SIGNAL }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, NF_SIGNAL }, + { winhttp_connect, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED }, + { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, NF_WINE_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, NF_WINE_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, NF_WINE_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, NF_WINE_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT }, + { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE }, + { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, NF_WINE_ALLOW }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, NF_WINE_ALLOW }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, NF_SIGNAL }, + { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, NF_WINE_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, NF_WINE_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT }, + { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE }, + { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, NF_WINE_ALLOW }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, NF_WINE_ALLOW }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, NF_SIGNAL }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, NF_SIGNAL } }; static void setup_test( struct info *info, enum api function, unsigned int line ) { + if (info->wait) ResetEvent( info->wait ); info->function = function; info->line = line; + while (info->index < info->count && info->test[info->index].function != function + && (info->test[info->index].flags & (NF_ALLOW | NF_WINE_ALLOW))) + info->index++; + ok_(__FILE__,line)(info->test[info->index].function == function, + "unexpected function %u, expected %u. probably some notifications were missing\n", + info->test[info->index].function, function); +} + +static void end_test( struct info *info, unsigned int line ) +{ + ok_(__FILE__,line)(info->index == info->count, "some notifications were missing: %x\n", + info->test[info->index].status); } static void test_connection_cache( void ) @@ -166,7 +189,7 @@ info.test = cache_test; info.count = sizeof(cache_test) / sizeof(cache_test[0]); info.index = 0; - info.wait = NULL; + info.wait = CreateEventW( NULL, FALSE, FALSE, NULL ); ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 ); ok(ses != NULL, "failed to open session %u\n", GetLastError()); @@ -189,7 +212,7 @@ ok(con != NULL, "failed to open a connection %u\n", GetLastError()); setup_test( &info, winhttp_open_request, __LINE__ ); - req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 ); + req = WinHttpOpenRequest( con, NULL, tests_hello_html, NULL, NULL, NULL, 0 ); ok(req != NULL, "failed to open a request %u\n", GetLastError()); setup_test( &info, winhttp_send_request, __LINE__ ); @@ -211,11 +234,13 @@ ok(ret, "failed unexpectedly %u\n", GetLastError()); ok(status == 200, "request failed unexpectedly %u\n", status); + ResetEvent( info.wait ); setup_test( &info, winhttp_close_handle, __LINE__ ); WinHttpCloseHandle( req ); + WaitForSingleObject( info.wait, INFINITE ); setup_test( &info, winhttp_open_request, __LINE__ ); - req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 ); + req = WinHttpOpenRequest( con, NULL, tests_hello_html, NULL, NULL, NULL, 0 ); ok(req != NULL, "failed to open a request %u\n", GetLastError()); ret = WinHttpSetOption( req, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) ); @@ -240,12 +265,12 @@ ok(ret, "failed unexpectedly %u\n", GetLastError()); ok(status == 200, "request failed unexpectedly %u\n", status); + ResetEvent( info.wait ); setup_test( &info, winhttp_close_handle, __LINE__ ); WinHttpCloseHandle( req ); - - setup_test( &info, winhttp_close_handle, __LINE__ ); WinHttpCloseHandle( req ); WinHttpCloseHandle( con ); + WaitForSingleObject( info.wait, INFINITE ); if (unload) { @@ -253,16 +278,16 @@ ok(status == WAIT_TIMEOUT, "got %08x\n", status); } + setup_test( &info, winhttp_close_handle, __LINE__ ); WinHttpCloseHandle( ses ); - - Sleep(2000); /* make sure connection is evicted from cache */ + WaitForSingleObject( info.wait, INFINITE ); + if (unload) { - status = WaitForSingleObject( event, 0 ); + status = WaitForSingleObject( event, 100 ); ok(status == WAIT_OBJECT_0, "got %08x\n", status); } - info.index = 0; ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 ); ok(ses != NULL, "failed to open session %u\n", GetLastError()); @@ -283,7 +308,7 @@ ok(con != NULL, "failed to open a connection %u\n", GetLastError()); setup_test( &info, winhttp_open_request, __LINE__ ); - req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 ); + req = WinHttpOpenRequest( con, NULL, tests_hello_html, NULL, NULL, NULL, 0 ); ok(req != NULL, "failed to open a request %u\n", GetLastError()); ret = WinHttpSetOption( req, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) ); @@ -308,11 +333,13 @@ ok(ret, "failed unexpectedly %u\n", GetLastError()); ok(status == 200, "request failed unexpectedly %u\n", status); + ResetEvent( info.wait ); setup_test( &info, winhttp_close_handle, __LINE__ ); WinHttpCloseHandle( req ); + WaitForSingleObject( info.wait, INFINITE ); setup_test( &info, winhttp_open_request, __LINE__ ); - req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 ); + req = WinHttpOpenRequest( con, NULL, tests_hello_html, NULL, NULL, NULL, 0 ); ok(req != NULL, "failed to open a request %u\n", GetLastError()); ret = WinHttpSetOption( req, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) ); @@ -341,6 +368,7 @@ done: WinHttpCloseHandle( req ); WinHttpCloseHandle( con ); + WaitForSingleObject( info.wait, INFINITE ); if (unload) { @@ -348,12 +376,15 @@ ok(status == WAIT_TIMEOUT, "got %08x\n", status); } + setup_test( &info, winhttp_close_handle, __LINE__ ); WinHttpCloseHandle( ses ); - - Sleep(2000); /* make sure connection is evicted from cache */ + WaitForSingleObject( info.wait, INFINITE ); + CloseHandle( info.wait ); + end_test( &info, __LINE__ ); + if (unload) { - status = WaitForSingleObject( event, 0 ); + status = WaitForSingleObject( event, 100 ); ok(status == WAIT_OBJECT_0, "got %08x\n", status); } @@ -364,28 +395,28 @@ { { winhttp_connect, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED }, { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED }, - { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, FALSE, TRUE }, - { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, FALSE, TRUE }, - { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER }, - { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, NF_WINE_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, NF_WINE_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, NF_WINE_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, NF_WINE_ALLOW }, { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST }, { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT }, { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE }, { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED }, { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT }, - { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, FALSE, TRUE, TRUE }, - { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, FALSE, TRUE, TRUE }, - { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, FALSE, FALSE, TRUE }, - { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, FALSE, FALSE, TRUE }, + { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, NF_ALLOW }, + { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, NF_ALLOW }, + { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, NF_ALLOW }, + { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, NF_ALLOW }, { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST }, { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REQUEST_SENT }, { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE }, { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, FALSE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, FALSE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, FALSE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE } + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, NF_WINE_ALLOW }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, NF_WINE_ALLOW }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, NF_SIGNAL } }; static void test_redirect( void ) @@ -398,7 +429,7 @@ info.test = redirect_test; info.count = sizeof(redirect_test) / sizeof(redirect_test[0]); info.index = 0; - info.wait = NULL; + info.wait = CreateEventW( NULL, FALSE, FALSE, NULL ); ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 ); ok(ses != NULL, "failed to open session %u\n", GetLastError()); @@ -413,7 +444,7 @@ ok(con != NULL, "failed to open a connection %u\n", GetLastError()); setup_test( &info, winhttp_open_request, __LINE__ ); - req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 ); + req = WinHttpOpenRequest( con, NULL, tests_redirect, NULL, NULL, NULL, 0 ); ok(req != NULL, "failed to open a request %u\n", GetLastError()); setup_test( &info, winhttp_send_request, __LINE__ ); @@ -440,40 +471,32 @@ WinHttpCloseHandle( req ); WinHttpCloseHandle( con ); WinHttpCloseHandle( ses ); + WaitForSingleObject( info.wait, INFINITE ); + CloseHandle( info.wait ); + end_test( &info, __LINE__ ); } static const struct notification async_test[] = { { winhttp_connect, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED }, { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED }, - { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, FALSE, TRUE }, - { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, FALSE, TRUE }, - { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER }, - { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, NF_WINE_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, NF_WINE_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, NF_WINE_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, NF_WINE_ALLOW }, { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST }, { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT }, - { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE, NF_SIGNAL }, { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE }, { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED }, - { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REDIRECT }, - { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, FALSE, TRUE, TRUE }, - { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, FALSE, TRUE, TRUE }, - { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, FALSE, FALSE, TRUE }, - { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, FALSE, FALSE, TRUE }, - { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST }, - { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_REQUEST_SENT }, - { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE }, - { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED }, - { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE }, - { winhttp_query_data, WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE }, - { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, FALSE, TRUE }, - { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, FALSE, TRUE }, - { winhttp_read_data, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, FALSE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, FALSE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, FALSE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, FALSE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE }, - { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, TRUE, TRUE } + { winhttp_receive_response, WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE, NF_SIGNAL }, + { winhttp_query_data, WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE, NF_SIGNAL }, + { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, NF_ALLOW }, + { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, NF_ALLOW }, + { winhttp_read_data, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, NF_SIGNAL }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, NF_SIGNAL } }; static void test_async( void ) @@ -520,7 +543,7 @@ setup_test( &info, winhttp_open_request, __LINE__ ); SetLastError( 0xdeadbeef ); - req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 ); + req = WinHttpOpenRequest( con, NULL, tests_hello_html, NULL, NULL, NULL, 0 ); err = GetLastError(); ok(req != NULL, "failed to open a request %u\n", err); ok(err == ERROR_SUCCESS, "got %u\n", err); @@ -570,11 +593,8 @@ WaitForSingleObject( info.wait, INFINITE ); setup_test( &info, winhttp_read_data, __LINE__ ); - SetLastError( 0xdeadbeef ); ret = WinHttpReadData( req, buffer, sizeof(buffer), NULL ); - err = GetLastError(); ok(ret, "failed to read data %u\n", err); - ok(err == ERROR_SUCCESS, "got %u\n", err); WaitForSingleObject( info.wait, INFINITE ); @@ -588,8 +608,8 @@ ok(status == WAIT_TIMEOUT, "got %08x\n", status); } WinHttpCloseHandle( ses ); - - WaitForSingleObject( info.wait, INFINITE ); + WaitForSingleObject( info.wait, INFINITE ); + end_test( &info, __LINE__ ); if (unload) { @@ -598,12 +618,430 @@ } CloseHandle( event ); CloseHandle( info.wait ); + end_test( &info, __LINE__ ); +} + +static const char okmsg[] = +"HTTP/1.1 200 OK\r\n" +"Server: winetest\r\n" +"\r\n"; + +static const char page1[] = +"<HTML>\r\n" +"<HEAD><TITLE>winhttp test page</TITLE></HEAD>\r\n" +"<BODY>The quick brown fox jumped over the lazy dog<P></BODY>\r\n" +"</HTML>\r\n\r\n"; + +struct server_info +{ + HANDLE event; + int port; +}; + +static int server_socket; +static HANDLE server_socket_available, server_socket_done; + +static DWORD CALLBACK server_thread(LPVOID param) +{ + struct server_info *si = param; + int r, c = -1, i, on; + SOCKET s; + struct sockaddr_in sa; + char buffer[0x100]; + WSADATA wsaData; + int last_request = 0; + + WSAStartup(MAKEWORD(1,1), &wsaData); + + s = socket(AF_INET, SOCK_STREAM, 0); + if (s == INVALID_SOCKET) + return 1; + + on = 1; + setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof on); + + memset(&sa, 0, sizeof sa); + sa.sin_family = AF_INET; + sa.sin_port = htons(si->port); + sa.sin_addr.S_un.S_addr = inet_addr("127.0.0.1"); + + r = bind(s, (struct sockaddr *)&sa, sizeof(sa)); + if (r < 0) + return 1; + + listen(s, 0); + SetEvent(si->event); + do + { + if (c == -1) c = accept(s, NULL, NULL); + + memset(buffer, 0, sizeof buffer); + for(i = 0; i < sizeof buffer - 1; i++) + { + r = recv(c, &buffer[i], 1, 0); + if (r != 1) + break; + if (i < 4) continue; + if (buffer[i - 2] == '\n' && buffer[i] == '\n' && + buffer[i - 3] == '\r' && buffer[i - 1] == '\r') + break; + } + if (strstr(buffer, "GET /quit")) + { + send(c, okmsg, sizeof okmsg - 1, 0); + send(c, page1, sizeof page1 - 1, 0); + last_request = 1; + } + else if(strstr(buffer, "GET /socket")) + { + server_socket = c; + SetEvent(server_socket_available); + WaitForSingleObject(server_socket_done, INFINITE); + ResetEvent(server_socket_available); + } + shutdown(c, 2); + closesocket(c); + c = -1; + } while (!last_request); + + closesocket(s); + return 0; +} + +static void test_basic_request(int port, const WCHAR *verb, const WCHAR *path) +{ + HINTERNET ses, con, req; + char buffer[0x100]; + DWORD count, status, size; + BOOL ret; + + ses = WinHttpOpen(NULL, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0); + ok(ses != NULL, "failed to open session %u\n", GetLastError()); + + con = WinHttpConnect(ses, localhostW, port, 0); + ok(con != NULL, "failed to open a connection %u\n", GetLastError()); + + req = WinHttpOpenRequest(con, verb, path, NULL, NULL, NULL, 0); + ok(req != NULL, "failed to open a request %u\n", GetLastError()); + + ret = WinHttpSendRequest(req, NULL, 0, NULL, 0, 0, 0); + ok(ret, "failed to send request %u\n", GetLastError()); + + ret = WinHttpReceiveResponse(req, NULL); + ok(ret, "failed to receive response %u\n", GetLastError()); + + status = 0xdeadbeef; + size = sizeof(status); + ret = WinHttpQueryHeaders(req, WINHTTP_QUERY_STATUS_CODE|WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL); + ok(ret, "failed to query status code %u\n", GetLastError()); + ok(status == HTTP_STATUS_OK, "request failed unexpectedly %u\n", status); + + count = 0; + memset(buffer, 0, sizeof(buffer)); + ret = WinHttpReadData(req, buffer, sizeof buffer, &count); + ok(ret, "failed to read data %u\n", GetLastError()); + ok(count == sizeof page1 - 1, "count was wrong\n"); + ok(!memcmp(buffer, page1, sizeof page1), "http data wrong\n"); + + WinHttpCloseHandle(req); + WinHttpCloseHandle(con); + WinHttpCloseHandle(ses); +} + +static const struct notification open_socket_request_test[] = +{ + { winhttp_connect, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED }, + { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, NF_ALLOW }, /* some versions call it twice. why? */ + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE, NF_SIGNAL } +}; + +static const struct notification reuse_socket_request_test[] = +{ + { winhttp_connect, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED }, + { winhttp_open_request, WINHTTP_CALLBACK_STATUS_HANDLE_CREATED }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_REQUEST_SENT }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE, NF_SIGNAL }, +}; + +static void open_async_request(int port, struct test_request *req, struct info *info, const WCHAR *path, BOOL reuse_connection) +{ + BOOL ret; + + info->index = 0; + if (reuse_connection) + { + info->test = reuse_socket_request_test; + info->count = sizeof(reuse_socket_request_test) / sizeof(reuse_socket_request_test[0]); + } + else + { + info->test = open_socket_request_test; + info->count = sizeof(open_socket_request_test) / sizeof(open_socket_request_test[0]); + } + + req->session = WinHttpOpen( user_agent, 0, NULL, NULL, WINHTTP_FLAG_ASYNC ); + ok(req->session != NULL, "failed to open session %u\n", GetLastError()); + + WinHttpSetOption( req->session, WINHTTP_OPTION_CONTEXT_VALUE, &info, sizeof(struct info *) ); + WinHttpSetStatusCallback( req->session, check_notification, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 ); + + setup_test( info, winhttp_connect, __LINE__ ); + req->connection = WinHttpConnect( req->session, localhostW, port, 0 ); + ok(req->connection != NULL, "failed to open a connection %u\n", GetLastError()); + + setup_test( info, winhttp_open_request, __LINE__ ); + req->request = WinHttpOpenRequest( req->connection, NULL, path, NULL, NULL, NULL, 0 ); + ok(req->request != NULL, "failed to open a request %u\n", GetLastError()); + + setup_test( info, winhttp_send_request, __LINE__ ); + ret = WinHttpSendRequest( req->request, NULL, 0, NULL, 0, 0, 0 ); + ok(ret, "failed to send request %u\n", GetLastError()); +} + +static void open_socket_request(int port, struct test_request *req, struct info *info) +{ + static const WCHAR socketW[] = {'/','s','o','c','k','e','t',0}; + + ResetEvent( server_socket_done ); + open_async_request( port, req, info, socketW, FALSE ); + WaitForSingleObject( server_socket_available, INFINITE ); +} + +static const struct notification server_reply_test[] = +{ + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, NF_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, NF_ALLOW }, + { winhttp_send_request, WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE, NF_SIGNAL } +}; + +static void server_send_reply(struct test_request *req, struct info *info, const char *msg) +{ + BOOL ret; + + send( server_socket, msg, strlen( msg ), 0 ); + WaitForSingleObject( info->wait, INFINITE ); + + info->test = server_reply_test; + info->count = sizeof(server_reply_test) / sizeof(server_reply_test[0]); + info->index = 0; + setup_test( info, winhttp_send_request, __LINE__ ); + ret = WinHttpReceiveResponse( req->request, NULL ); + ok(ret, "failed to receive response %u\n", GetLastError()); + + WaitForSingleObject( info->wait, INFINITE ); + end_test( info, __LINE__ ); +} + +#define server_read_data(a) _server_read_data(a,__LINE__) +static void _server_read_data(const char *expect_prefix, unsigned int line) +{ + char buf[1024]; + DWORD size, len; + + size = recv( server_socket, buf, sizeof(buf), 0 ); + len = strlen( expect_prefix ); + ok_(__FILE__,line)(size > len, "data too short\n"); + if (size >= len) + { + buf[len] = 0; + ok_(__FILE__,line)(!strcmp( buf, expect_prefix ), "unexpected data \"%s\"\n", buf); + } +} + +static const struct notification close_request_test[] = +{ + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, NF_SIGNAL } +}; + +static const struct notification close_allow_connection_close_request_test[] = +{ + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, NF_ALLOW }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, NF_ALLOW }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING }, + { winhttp_close_handle, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, NF_SIGNAL } +}; + +static void close_request(struct test_request *req, struct info *info, BOOL allow_closing_connection) +{ + BOOL ret; + + if (allow_closing_connection) + { + info->test = close_allow_connection_close_request_test; + info->count = sizeof(close_allow_connection_close_request_test)/sizeof(*close_allow_connection_close_request_test); + } + else + { + info->test = close_request_test; + info->count = sizeof(close_request_test)/sizeof(*close_request_test); + } + info->index = 0; + setup_test( info, winhttp_close_handle, __LINE__ ); + + ret = WinHttpCloseHandle( req->request ); + ok(ret, "WinHttpCloseHandle failed: %u\n", GetLastError()); + ret = WinHttpCloseHandle( req->connection ); + ok(ret, "WinHttpCloseHandle failed: %u\n", GetLastError()); + ret = WinHttpCloseHandle( req->session ); + ok(ret, "WinHttpCloseHandle failed: %u\n", GetLastError()); + + WaitForSingleObject( info->wait, INFINITE ); + end_test( info, __LINE__ ); +} + +static const struct notification read_test[] = +{ + { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, NF_ALLOW }, + { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, NF_ALLOW }, + { winhttp_read_data, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, NF_SIGNAL } +}; + +static const struct notification read_allow_close_test[] = +{ + { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, NF_ALLOW }, + { winhttp_read_data, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, NF_ALLOW }, + { winhttp_read_data, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, NF_ALLOW }, + { winhttp_read_data, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, NF_ALLOW }, + { winhttp_read_data, WINHTTP_CALLBACK_STATUS_READ_COMPLETE, NF_SIGNAL } +}; + +#define read_request_data(a,b,c,d) _read_request_data(a,b,c,d,__LINE__) +static void _read_request_data(struct test_request *req, struct info *info, const char *expected_data, BOOL closing_connection, unsigned line) +{ + char buffer[1024]; + DWORD read, len; + BOOL ret; + + if (closing_connection) + { + info->test = read_allow_close_test; + info->count = sizeof(read_allow_close_test)/sizeof(*read_allow_close_test); + } + else + { + info->test = read_test; + info->count = sizeof(read_test)/sizeof(*read_test); + } + info->index = 0; + + setup_test( info, winhttp_read_data, line ); + memset(buffer, '?', sizeof(buffer)); + read = 0xdeadbeef; + ret = WinHttpReadData( req->request, buffer, sizeof(buffer), &read ); + ok(ret, "failed to read data %u\n", GetLastError()); + + WaitForSingleObject( info->wait, INFINITE ); + + len = strlen(expected_data); + ok(!memcmp(buffer, expected_data, len), "unexpeceted data\n"); +} + +static void test_persistent_connection(int port) +{ + struct test_request req; + struct info info; + + static const WCHAR testW[] = {'/','t','e','s','t',0}; + + trace("Testing persistent connection...\n"); + + info.wait = CreateEventW( NULL, FALSE, FALSE, NULL ); + + open_socket_request( port, &req, &info ); + server_send_reply( &req, &info, + "HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "Connection: keep-alive\r\n" + "Content-Length: 1\r\n" + "\r\n" + "X" ); + read_request_data( &req, &info, "X", FALSE ); + close_request( &req, &info, FALSE ); + + /* chunked connection test */ + open_async_request( port, &req, &info, testW, TRUE ); + server_read_data( "GET /test HTTP/1.1\r\n" ); + server_send_reply( &req, &info, + "HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "Transfer-Encoding: chunked\r\n" + "Connection: keep-alive\r\n" + "\r\n" + "9\r\n123456789\r\n" + "0\r\n\r\n" ); + read_request_data( &req, &info, "123456789", FALSE ); + close_request( &req, &info, FALSE ); + + /* HTTP/1.1 connections are persistent by default, no additional header is needed */ + open_async_request( port, &req, &info, testW, TRUE ); + server_read_data( "GET /test HTTP/1.1\r\n" ); + server_send_reply( &req, &info, + "HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "Content-Length: 2\r\n" + "\r\n" + "xx" ); + read_request_data( &req, &info, "xx", FALSE ); + close_request( &req, &info, FALSE ); + + open_async_request( port, &req, &info, testW, TRUE ); + server_read_data( "GET /test HTTP/1.1\r\n" ); + server_send_reply( &req, &info, + "HTTP/1.1 200 OK\r\n" + "Server: winetest\r\n" + "Content-Length: 2\r\n" + "Connection: close\r\n" + "\r\n" + "yy" ); + close_request( &req, &info, TRUE ); + + SetEvent( server_socket_done ); + CloseHandle( info.wait ); } START_TEST (notification) { + static const WCHAR quitW[] = {'/','q','u','i','t',0}; + struct server_info si; + HANDLE thread; + DWORD ret; + test_connection_cache(); test_redirect(); - Sleep(2000); /* make sure previous connection is evicted from cache */ test_async(); -} + + si.event = CreateEventW( NULL, 0, 0, NULL ); + si.port = 7533; + + thread = CreateThread( NULL, 0, server_thread, (LPVOID)&si, 0, NULL ); + ok(thread != NULL, "failed to create thread %u\n", GetLastError()); + + server_socket_available = CreateEventW( NULL, 0, 0, NULL ); + server_socket_done = CreateEventW( NULL, 0, 0, NULL ); + + ret = WaitForSingleObject( si.event, 10000 ); + ok(ret == WAIT_OBJECT_0, "failed to start winhttp test server %u\n", GetLastError()); + if (ret != WAIT_OBJECT_0) + return; + + test_persistent_connection( si.port ); + + /* send the basic request again to shutdown the server thread */ + test_basic_request( si.port, NULL, quitW ); + + WaitForSingleObject( thread, 3000 ); + CloseHandle( thread ); + CloseHandle( server_socket_available ); + CloseHandle( server_socket_done ); +}
7 years, 3 months
1
0
0
0
[akhaldi] 75944: [WINHTTP] Sync with Wine Staging 2.16. CORE-13762 d0813b7 winhttp: Avoid returning while holding a lock (Coverity). 5a61913 winhttp: Rename host_t to hostdata_t. 2a99f0e winhttp: P...
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:17:43 2017 New Revision: 75944 URL:
http://svn.reactos.org/svn/reactos?rev=75944&view=rev
Log: [WINHTTP] Sync with Wine Staging 2.16. CORE-13762 d0813b7 winhttp: Avoid returning while holding a lock (Coverity). 5a61913 winhttp: Rename host_t to hostdata_t. 2a99f0e winhttp: Periodically free outdated connections. 5226865 winhttp: Cache and reuse persistent HTTP connections. e0e8a3f winhttp: Introduce global connected hosts store and keep reference to host in netconn_t. d1d65c9 winhttp: Merge netconn_create and netconn_connect implementations. 3e60241 winhttp: Store socked address in netconn_t. e129023 winhttp: Pass socket address as sockaddr_storage to netconn_connect. c2f464d winhttp: Get rid of no longer needed netconn_init. 8c9df5b winhttp: Use notification flags to explicitly mark notifications that should signal an event. c502629 winhttp: Allocate netconn_t separately from request_t. c06104c winhttp: Store security_flags in request_t instead of netconn_t. f2bb206 winhttp: Reset content length when a redirect creates a new connection. 0923897 winhttp: Only read as much data as advertized when draining content. Modified: trunk/reactos/dll/win32/winhttp/CMakeLists.txt trunk/reactos/dll/win32/winhttp/inet_ntop.c trunk/reactos/dll/win32/winhttp/main.c trunk/reactos/dll/win32/winhttp/net.c trunk/reactos/dll/win32/winhttp/request.c trunk/reactos/dll/win32/winhttp/session.c trunk/reactos/dll/win32/winhttp/winhttp_private.h trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/winhttp/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/CMakeLis…
============================================================================== --- trunk/reactos/dll/win32/winhttp/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/CMakeLists.txt [iso-8859-1] Sun Sep 24 11:17:43 2017 @@ -1,3 +1,6 @@ + +remove_definitions(-D_WIN32_WINNT=0x502) +add_definitions(-D_WIN32_WINNT=0x600) add_definitions( -D__WINESRC__ @@ -27,7 +30,7 @@ set_module_type(winhttp win32dll) target_link_libraries(winhttp uuid wine) add_delay_importlibs(winhttp oleaut32 ole32 crypt32 secur32) -add_importlibs(winhttp user32 advapi32 ws2_32 jsproxy msvcrt kernel32 ntdll) +add_importlibs(winhttp user32 advapi32 ws2_32 jsproxy kernel32_vista msvcrt kernel32 ntdll) add_dependencies(winhttp stdole2) add_pch(winhttp winhttp_private.h SOURCE) add_cd_file(TARGET winhttp DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/dll/win32/winhttp/inet_ntop.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/inet_nto…
============================================================================== --- trunk/reactos/dll/win32/winhttp/inet_ntop.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/inet_ntop.c [iso-8859-1] Sun Sep 24 11:17:43 2017 @@ -51,16 +51,18 @@ * author: * Paul Vixie, 1996. */ -const char * -inet_ntop(int af, const void *src, char *dst, size_t size) + +PCSTR +WSAAPI +inet_ntop(INT Family, PVOID pAddr, PSTR pStringBuf, size_t StringBufSize) { - switch (af) { + switch (Family) { case AF_INET: - return (inet_ntop4(src, dst, size)); + return (inet_ntop4(pAddr, pStringBuf, StringBufSize)); #ifdef INET6 case AF_INET6: - return (inet_ntop6(src, dst, size)); + return (inet_ntop6(pAddr, pStringBuf, StringBufSize)); #endif default: WSASetLastError(WSAEAFNOSUPPORT); Modified: trunk/reactos/dll/win32/winhttp/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/main.c?r…
============================================================================== --- trunk/reactos/dll/win32/winhttp/main.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/main.c [iso-8859-1] Sun Sep 24 11:17:43 2017 @@ -21,7 +21,7 @@ #include <rpcproxy.h> #include <httprequest.h> -static HINSTANCE instance; +HINSTANCE winhttp_instance; /****************************************************************** * DllMain (winhttp.@) @@ -31,7 +31,7 @@ switch(fdwReason) { case DLL_PROCESS_ATTACH: - instance = hInstDLL; + winhttp_instance = hInstDLL; DisableThreadLibraryCalls(hInstDLL); break; case DLL_PROCESS_DETACH: @@ -158,7 +158,7 @@ */ HRESULT WINAPI DllRegisterServer(void) { - return __wine_register_resources( instance ); + return __wine_register_resources( winhttp_instance ); } /*********************************************************************** @@ -166,5 +166,5 @@ */ HRESULT WINAPI DllUnregisterServer(void) { - return __wine_unregister_resources( instance ); + return __wine_unregister_resources( winhttp_instance ); } Modified: trunk/reactos/dll/win32/winhttp/net.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/net.c?re…
============================================================================== --- trunk/reactos/dll/win32/winhttp/net.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/net.c [iso-8859-1] Sun Sep 24 11:17:43 2017 @@ -298,13 +298,6 @@ #endif -BOOL netconn_init( netconn_t *conn ) -{ - memset(conn, 0, sizeof(*conn)); - conn->socket = -1; - return TRUE; -} - void netconn_unload( void ) { if(cred_handle_initialized) @@ -319,56 +312,38 @@ #endif } -BOOL netconn_connected( netconn_t *conn ) -{ - return (conn->socket != -1); -} - -BOOL netconn_create( netconn_t *conn, int domain, int type, int protocol ) -{ - if ((conn->socket = socket( domain, type, protocol )) == -1) - { - WARN("unable to create socket (%s)\n", strerror(errno)); - set_last_error( sock_get_error( errno ) ); - return FALSE; - } - return TRUE; -} - -BOOL netconn_close( netconn_t *conn ) -{ - int res; - - if (conn->secure) - { - heap_free( conn->peek_msg_mem ); - conn->peek_msg_mem = NULL; - conn->peek_msg = NULL; - conn->peek_len = 0; - heap_free(conn->ssl_buf); - conn->ssl_buf = NULL; - heap_free(conn->extra_buf); - conn->extra_buf = NULL; - conn->extra_len = 0; - DeleteSecurityContext(&conn->ssl_ctx); - conn->secure = FALSE; - } - res = closesocket( conn->socket ); - conn->socket = -1; - if (res == -1) - { - set_last_error( sock_get_error( errno ) ); - return FALSE; - } - return TRUE; -} - -BOOL netconn_connect( netconn_t *conn, const struct sockaddr *sockaddr, unsigned int addr_len, int timeout ) -{ +netconn_t *netconn_create( hostdata_t *host, const struct sockaddr_storage *sockaddr, int timeout ) +{ + netconn_t *conn; + unsigned int addr_len; BOOL ret = FALSE; int res; ULONG state; + conn = heap_alloc_zero(sizeof(*conn)); + if (!conn) return NULL; + conn->host = host; + conn->sockaddr = *sockaddr; + if ((conn->socket = socket( sockaddr->ss_family, SOCK_STREAM, 0 )) == -1) + { + WARN("unable to create socket (%s)\n", strerror(errno)); + set_last_error( sock_get_error( errno ) ); + heap_free(conn); + return NULL; + } + + switch (conn->sockaddr.ss_family) + { + case AF_INET: + addr_len = sizeof(struct sockaddr_in); + break; + case AF_INET6: + addr_len = sizeof(struct sockaddr_in6); + break; + default: + assert(0); + } + if (timeout > 0) { state = 1; @@ -378,7 +353,7 @@ for (;;) { res = 0; - if (connect( conn->socket, sockaddr, addr_len ) < 0) + if (connect( conn->socket, (const struct sockaddr *)&conn->sockaddr, addr_len ) < 0) { res = sock_get_error( errno ); if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS) @@ -436,11 +411,35 @@ { WARN("unable to connect to host (%d)\n", res); set_last_error( res ); - } - return ret; -} - -BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname ) + netconn_close( conn ); + return NULL; + } + return conn; +} + +BOOL netconn_close( netconn_t *conn ) +{ + int res; + + if (conn->secure) + { + heap_free( conn->peek_msg_mem ); + heap_free(conn->ssl_buf); + heap_free(conn->extra_buf); + DeleteSecurityContext(&conn->ssl_ctx); + } + res = closesocket( conn->socket ); + release_host( conn->host ); + heap_free(conn); + if (res == -1) + { + set_last_error( sock_get_error( errno ) ); + return FALSE; + } + return TRUE; +} + +BOOL netconn_secure_connect( netconn_t *conn, WCHAR *hostname, DWORD security_flags ) { SecBuffer out_buf = {0, SECBUFFER_TOKEN, NULL}, in_bufs[2] = {{0, SECBUFFER_TOKEN}, {0, SECBUFFER_EMPTY}}; SecBufferDesc out_desc = {SECBUFFER_VERSION, 1, &out_buf}, in_desc = {SECBUFFER_VERSION, 2, in_bufs}; @@ -540,7 +539,7 @@ status = QueryContextAttributesW(&ctx, SECPKG_ATTR_REMOTE_CERT_CONTEXT, (void*)&cert); if(status == SEC_E_OK) { - res = netconn_verify_cert(cert, hostname, conn->security_flags); + res = netconn_verify_cert(cert, hostname, security_flags); CertFreeCertificateContext(cert); if(res != ERROR_SUCCESS) { WARN("cert verify failed: %u\n", res); @@ -605,7 +604,6 @@ BOOL netconn_send( netconn_t *conn, const void *msg, size_t len, int *sent ) { - if (!netconn_connected( conn )) return FALSE; if (conn->secure) { const BYTE *ptr = msg; @@ -729,7 +727,6 @@ BOOL netconn_recv( netconn_t *conn, void *buf, size_t len, int flags, int *recvd ) { *recvd = 0; - if (!netconn_connected( conn )) return FALSE; if (!len) return TRUE; if (conn->secure) @@ -786,13 +783,7 @@ ULONG netconn_query_data_available( netconn_t *conn ) { - if(!netconn_connected(conn)) - return 0; - - if(conn->secure) - return conn->peek_len; - - return 0; + return conn->secure ? conn->peek_len : 0; } DWORD netconn_set_timeout( netconn_t *netconn, BOOL send, int value ) @@ -811,7 +802,37 @@ return ERROR_SUCCESS; } -static DWORD resolve_hostname( const WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr *sa, socklen_t *sa_len ) +BOOL netconn_is_alive( netconn_t *netconn ) +{ +#ifdef MSG_DONTWAIT + ssize_t len; + BYTE b; + + len = recv( netconn->socket, &b, 1, MSG_PEEK | MSG_DONTWAIT ); + return len == 1 || (len == -1 && errno == EWOULDBLOCK); +#elif defined(__MINGW32__) || defined(_MSC_VER) + ULONG mode; + int len; + char b; + + mode = 1; + if(!ioctlsocket(netconn->socket, FIONBIO, &mode)) + return FALSE; + + len = recv(netconn->socket, &b, 1, MSG_PEEK); + + mode = 0; + if(!ioctlsocket(netconn->socket, FIONBIO, &mode)) + return FALSE; + + return len == 1 || (len == -1 && WSAGetLastError() == WSAEWOULDBLOCK); +#else + FIXME("not supported on this platform\n"); + return TRUE; +#endif +} + +static DWORD resolve_hostname( const WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr_storage *sa ) { char *hostname; #ifdef HAVE_GETADDRINFO @@ -845,13 +866,6 @@ } } heap_free( hostname ); - if (*sa_len < res->ai_addrlen) - { - WARN("address too small\n"); - freeaddrinfo( res ); - return ERROR_WINHTTP_NAME_NOT_RESOLVED; - } - *sa_len = res->ai_addrlen; memcpy( sa, res->ai_addr, res->ai_addrlen ); /* Copy port */ switch (res->ai_family) @@ -877,13 +891,6 @@ LeaveCriticalSection( &cs_gethostbyname ); return ERROR_WINHTTP_NAME_NOT_RESOLVED; } - if (*sa_len < sizeof(struct sockaddr_in)) - { - WARN("address too small\n"); - LeaveCriticalSection( &cs_gethostbyname ); - return ERROR_WINHTTP_NAME_NOT_RESOLVED; - } - *sa_len = sizeof(struct sockaddr_in); memset( sa, 0, sizeof(struct sockaddr_in) ); memcpy( &sin->sin_addr, he->h_addr, he->h_length ); sin->sin_family = he->h_addrtype; @@ -896,19 +903,18 @@ struct resolve_args { - const WCHAR *hostname; - INTERNET_PORT port; - struct sockaddr *sa; - socklen_t *sa_len; + const WCHAR *hostname; + INTERNET_PORT port; + struct sockaddr_storage *sa; }; static DWORD CALLBACK resolve_proc( LPVOID arg ) { struct resolve_args *ra = arg; - return resolve_hostname( ra->hostname, ra->port, ra->sa, ra->sa_len ); -} - -BOOL netconn_resolve( WCHAR *hostname, INTERNET_PORT port, struct sockaddr *sa, socklen_t *sa_len, int timeout ) + return resolve_hostname( ra->hostname, ra->port, ra->sa ); +} + +BOOL netconn_resolve( WCHAR *hostname, INTERNET_PORT port, struct sockaddr_storage *sa, int timeout ) { DWORD ret; @@ -921,7 +927,6 @@ ra.hostname = hostname; ra.port = port; ra.sa = sa; - ra.sa_len = sa_len; thread = CreateThread( NULL, 0, resolve_proc, &ra, 0, NULL ); if (!thread) return FALSE; @@ -931,7 +936,7 @@ else ret = ERROR_WINHTTP_TIMEOUT; CloseHandle( thread ); } - else ret = resolve_hostname( hostname, port, sa, sa_len ); + else ret = resolve_hostname( hostname, port, sa ); if (ret) { Modified: trunk/reactos/dll/win32/winhttp/request.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/request.…
============================================================================== --- trunk/reactos/dll/win32/winhttp/request.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/request.c [iso-8859-1] Sun Sep 24 11:17:43 2017 @@ -31,6 +31,8 @@ #include <httprequestid.h> #include "inet_ntop.c" + +#define DEFAULT_KEEP_ALIVE_TIMEOUT 30000 static const WCHAR attr_accept[] = {'A','c','c','e','p','t',0}; static const WCHAR attr_accept_charset[] = {'A','c','c','e','p','t','-','C','h','a','r','s','e','t', 0}; @@ -540,7 +542,7 @@ static const WCHAR http[] = { 'h','t','t','p',0 }; static const WCHAR https[] = { 'h','t','t','p','s',0 }; static const WCHAR fmt[] = { '%','s',':','/','/','%','s',0 }; - LPCWSTR scheme = request->netconn.secure ? https : http; + LPCWSTR scheme = (request->netconn ? request->netconn->secure : (request->hdr.flags & WINHTTP_FLAG_SECURE)) ? https : http; int len; len = strlenW( scheme ) + strlenW( request->connect->hostname ); @@ -945,7 +947,7 @@ { int len = strlen( req_ascii ), bytes_sent; - ret = netconn_send( &request->netconn, req_ascii, len, &bytes_sent ); + ret = netconn_send( request->netconn, req_ascii, len, &bytes_sent ); heap_free( req_ascii ); if (ret) ret = read_reply( request ); @@ -959,12 +961,12 @@ #define INET6_ADDRSTRLEN 46 #endif -static WCHAR *addr_to_str( struct sockaddr *addr ) +static WCHAR *addr_to_str( struct sockaddr_storage *addr ) { char buf[INET6_ADDRSTRLEN]; void *src; - switch (addr->sa_family) + switch (addr->ss_family) { case AF_INET: src = &((struct sockaddr_in *)addr)->sin_addr; @@ -973,79 +975,258 @@ src = &((struct sockaddr_in6 *)addr)->sin6_addr; break; default: - WARN("unsupported address family %d\n", addr->sa_family); + WARN("unsupported address family %d\n", addr->ss_family); return NULL; } - if (!inet_ntop( addr->sa_family, src, buf, sizeof(buf) )) return NULL; + if (!inet_ntop( addr->ss_family, src, buf, sizeof(buf) )) return NULL; return strdupAW( buf ); } +static CRITICAL_SECTION connection_pool_cs; +static CRITICAL_SECTION_DEBUG connection_pool_debug = +{ + 0, 0, &connection_pool_cs, + { &connection_pool_debug.ProcessLocksList, &connection_pool_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": connection_pool_cs") } +}; +static CRITICAL_SECTION connection_pool_cs = { &connection_pool_debug, -1, 0, 0, 0, 0 }; + +static struct list connection_pool = LIST_INIT( connection_pool ); + +void release_host( hostdata_t *host ) +{ + LONG ref; + + EnterCriticalSection( &connection_pool_cs ); + if (!(ref = --host->ref)) list_remove( &host->entry ); + LeaveCriticalSection( &connection_pool_cs ); + if (ref) return; + + assert( list_empty( &host->connections ) ); + heap_free( host->hostname ); + heap_free( host ); +} + +static BOOL connection_collector_running; + +static DWORD WINAPI connection_collector(void *arg) +{ + unsigned int remaining_connections; + netconn_t *netconn, *next_netconn; + hostdata_t *host, *next_host; + ULONGLONG now; + + do + { + /* FIXME: Use more sophisticated method */ + Sleep(5000); + remaining_connections = 0; + now = GetTickCount64(); + + EnterCriticalSection(&connection_pool_cs); + + LIST_FOR_EACH_ENTRY_SAFE(host, next_host, &connection_pool, hostdata_t, entry) + { + LIST_FOR_EACH_ENTRY_SAFE(netconn, next_netconn, &host->connections, netconn_t, entry) + { + if (netconn->keep_until < now) + { + TRACE("freeing %p\n", netconn); + list_remove(&netconn->entry); + netconn_close(netconn); + } + else + { + remaining_connections++; + } + } + } + + if (!remaining_connections) connection_collector_running = FALSE; + + LeaveCriticalSection(&connection_pool_cs); + } while(remaining_connections); + + FreeLibraryAndExitThread( winhttp_instance, 0 ); +} + +static void cache_connection( netconn_t *netconn ) +{ + TRACE( "caching connection %p\n", netconn ); + + EnterCriticalSection( &connection_pool_cs ); + + netconn->keep_until = GetTickCount64() + DEFAULT_KEEP_ALIVE_TIMEOUT; + list_add_head( &netconn->host->connections, &netconn->entry ); + + if (!connection_collector_running) + { + HMODULE module; + HANDLE thread; + + GetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (const WCHAR*)winhttp_instance, &module ); + + thread = CreateThread(NULL, 0, connection_collector, NULL, 0, NULL); + if (thread) + { + CloseHandle( thread ); + connection_collector_running = TRUE; + } + else + { + FreeLibrary( winhttp_instance ); + } + } + + LeaveCriticalSection( &connection_pool_cs ); +} + static BOOL open_connection( request_t *request ) { + BOOL is_secure = request->hdr.flags & WINHTTP_FLAG_SECURE; + hostdata_t *host = NULL, *iter; + netconn_t *netconn = NULL; connect_t *connect; WCHAR *addressW = NULL; INTERNET_PORT port; - socklen_t slen; - struct sockaddr *saddr; DWORD len; - if (netconn_connected( &request->netconn )) goto done; + if (request->netconn) goto done; connect = request->connect; port = connect->serverport ? connect->serverport : (request->hdr.flags & WINHTTP_FLAG_SECURE ? 443 : 80); - saddr = (struct sockaddr *)&connect->sockaddr; - slen = sizeof(struct sockaddr); + + EnterCriticalSection( &connection_pool_cs ); + + LIST_FOR_EACH_ENTRY( iter, &connection_pool, hostdata_t, entry ) + { + if (iter->port == port && !strcmpW( connect->servername, iter->hostname ) && !is_secure == !iter->secure) + { + host = iter; + host->ref++; + break; + } + } + + if (!host) + { + if ((host = heap_alloc( sizeof(*host) ))) + { + host->ref = 1; + host->secure = is_secure; + host->port = port; + list_init( &host->connections ); + if ((host->hostname = strdupW( connect->servername ))) + { + list_add_head( &connection_pool, &host->entry ); + } + else + { + heap_free( host ); + host = NULL; + } + } + } + + LeaveCriticalSection( &connection_pool_cs ); + + if (!host) return FALSE; + + for (;;) + { + EnterCriticalSection( &connection_pool_cs ); + if (!list_empty( &host->connections )) + { + netconn = LIST_ENTRY( list_head( &host->connections ), netconn_t, entry ); + list_remove( &netconn->entry ); + } + LeaveCriticalSection( &connection_pool_cs ); + if (!netconn) break; + + if (netconn_is_alive( netconn )) break; + TRACE("connection %p no longer alive, closing\n", netconn); + netconn_close( netconn ); + netconn = NULL; + } + + if (!connect->resolved && netconn) + { + connect->sockaddr = netconn->sockaddr; + connect->resolved = TRUE; + } if (!connect->resolved) { - len = strlenW( connect->servername ) + 1; - send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, connect->servername, len ); - - if (!netconn_resolve( connect->servername, port, saddr, &slen, request->resolve_timeout )) return FALSE; + len = strlenW( host->hostname ) + 1; + send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, host->hostname, len ); + + if (!netconn_resolve( host->hostname, port, &connect->sockaddr, request->resolve_timeout )) + { + release_host( host ); + return FALSE; + } connect->resolved = TRUE; - if (!(addressW = addr_to_str( saddr ))) return FALSE; + if (!(addressW = addr_to_str( &connect->sockaddr ))) + { + release_host( host ); + return FALSE; + } len = strlenW( addressW ) + 1; send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_NAME_RESOLVED, addressW, len ); } - if (!addressW && !(addressW = addr_to_str( saddr ))) return FALSE; - TRACE("connecting to %s:%u\n", debugstr_w(addressW), port); - - send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, addressW, 0 ); - - if (!netconn_create( &request->netconn, saddr->sa_family, SOCK_STREAM, 0 )) - { - heap_free( addressW ); - return FALSE; - } - netconn_set_timeout( &request->netconn, TRUE, request->send_timeout ); - netconn_set_timeout( &request->netconn, FALSE, request->recv_timeout ); - if (!netconn_connect( &request->netconn, saddr, slen, request->connect_timeout )) - { - netconn_close( &request->netconn ); - heap_free( addressW ); - return FALSE; - } - if (request->hdr.flags & WINHTTP_FLAG_SECURE) - { - if (connect->session->proxy_server && - strcmpiW( connect->hostname, connect->servername )) - { - if (!secure_proxy_connect( request )) + + if (!netconn) + { + if (!addressW && !(addressW = addr_to_str( &connect->sockaddr ))) + { + release_host( host ); + return FALSE; + } + + TRACE("connecting to %s:%u\n", debugstr_w(addressW), port); + + send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER, addressW, 0 ); + + if (!(netconn = netconn_create( host, &connect->sockaddr, request->connect_timeout ))) + { + heap_free( addressW ); + release_host( host ); + return FALSE; + } + netconn_set_timeout( netconn, TRUE, request->send_timeout ); + netconn_set_timeout( netconn, FALSE, request->recv_timeout ); + if (is_secure) + { + if (connect->session->proxy_server && + strcmpiW( connect->hostname, connect->servername )) + { + if (!secure_proxy_connect( request )) + { + heap_free( addressW ); + netconn_close( netconn ); + return FALSE; + } + } + if (!netconn_secure_connect( netconn, connect->hostname, request->security_flags )) { heap_free( addressW ); + netconn_close( netconn ); return FALSE; } } - if (!netconn_secure_connect( &request->netconn, connect->hostname )) - { - netconn_close( &request->netconn ); - heap_free( addressW ); - return FALSE; - } - } - - send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, addressW, strlenW(addressW) + 1 ); + + request->netconn = netconn; + send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER, addressW, strlenW(addressW) + 1 ); + } + else + { + TRACE("using connection %p\n", netconn); + + netconn_set_timeout( netconn, TRUE, request->send_timeout ); + netconn_set_timeout( netconn, FALSE, request->recv_timeout ); + request->netconn = netconn; + } done: request->read_pos = request->read_size = 0; @@ -1058,10 +1239,11 @@ void close_connection( request_t *request ) { - if (!netconn_connected( &request->netconn )) return; + if (!request->netconn) return; send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CLOSING_CONNECTION, 0, 0 ); - netconn_close( &request->netconn ); + netconn_close( request->netconn ); + request->netconn = NULL; send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_CONNECTION_CLOSED, 0, 0 ); } @@ -1127,7 +1309,7 @@ if (notify) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_RECEIVING_RESPONSE, NULL, 0 ); - ret = netconn_recv( &request->netconn, request->read_buf + request->read_size, + ret = netconn_recv( request->netconn, request->read_buf + request->read_size, maxlen - request->read_size, 0, &len ); if (notify) send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_RESPONSE_RECEIVED, &len, sizeof(len) ); @@ -1229,6 +1411,8 @@ WCHAR connection[20]; DWORD size = sizeof(connection); + if (!request->netconn) return; + if (request->hdr.disable_flags & WINHTTP_DISABLE_KEEP_ALIVE) close = TRUE; else if (query_headers( request, WINHTTP_QUERY_CONNECTION, NULL, connection, &size, NULL ) || query_headers( request, WINHTTP_QUERY_PROXY_CONNECTION, NULL, connection, &size, NULL )) @@ -1236,7 +1420,14 @@ if (!strcmpiW( connection, closeW )) close = TRUE; } else if (!strcmpW( request->version, http1_0 )) close = TRUE; - if (close) close_connection( request ); + if (close) + { + close_connection( request ); + return; + } + + cache_connection( request->netconn ); + request->netconn = NULL; } /* return the size of data available to be read immediately */ @@ -1291,13 +1482,20 @@ /* read any content returned by the server so that the connection can be reused */ static void drain_content( request_t *request ) { - DWORD bytes_read; + DWORD size, bytes_read, bytes_total = 0, bytes_left = request->content_length - request->content_read; char buffer[2048]; refill_buffer( request, FALSE ); for (;;) { - if (!read_data( request, buffer, sizeof(buffer), &bytes_read, FALSE ) || !bytes_read) return; + if (request->read_chunked) size = sizeof(buffer); + else + { + if (bytes_total >= bytes_left) return; + size = min( sizeof(buffer), bytes_left - bytes_total ); + } + if (!read_data( request, buffer, size, &bytes_read, FALSE ) || !bytes_read) return; + bytes_total += bytes_read; } } @@ -1362,13 +1560,13 @@ send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_SENDING_REQUEST, NULL, 0 ); - ret = netconn_send( &request->netconn, req_ascii, len, &bytes_sent ); + ret = netconn_send( request->netconn, req_ascii, len, &bytes_sent ); heap_free( req_ascii ); if (!ret) goto end; if (optional_len) { - if (!netconn_send( &request->netconn, optional, optional_len, &bytes_sent )) goto end; + if (!netconn_send( request->netconn, optional, optional_len, &bytes_sent )) goto end; request->optional = optional; request->optional_len = optional_len; len += optional_len; @@ -2145,7 +2343,7 @@ WCHAR *versionW, *status_textW, *raw_headers; WCHAR status_codeW[4]; /* sizeof("nnn") */ - if (!netconn_connected( &request->netconn )) return FALSE; + if (!request->netconn) return FALSE; do { @@ -2331,11 +2529,11 @@ connect->hostport = port; if (!(ret = set_server_for_hostname( connect, hostname, port ))) goto end; - netconn_close( &request->netconn ); - if (!(ret = netconn_init( &request->netconn ))) goto end; + netconn_close( request->netconn ); + request->netconn = NULL; + request->content_length = request->content_read = 0; request->read_pos = request->read_size = 0; - request->read_chunked = FALSE; - request->read_chunked_eof = FALSE; + request->read_chunked = request->read_chunked_eof = FALSE; } else heap_free( hostname ); @@ -2483,14 +2681,14 @@ if (end_of_read_data( request )) goto done; count = get_available_data( request ); - if (!request->read_chunked) - count += netconn_query_data_available( &request->netconn ); + if (!request->read_chunked && request->netconn) + count += netconn_query_data_available( request->netconn ); if (!count) { refill_buffer( request, async ); count = get_available_data( request ); - if (!request->read_chunked) - count += netconn_query_data_available( &request->netconn ); + if (!request->read_chunked && request->netconn) + count += netconn_query_data_available( request->netconn ); } done: @@ -2603,7 +2801,7 @@ BOOL ret; int num_bytes; - ret = netconn_send( &request->netconn, buffer, to_write, &num_bytes ); + ret = netconn_send( request->netconn, buffer, to_write, &num_bytes ); if (async) { Modified: trunk/reactos/dll/win32/winhttp/session.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/session.…
============================================================================== --- trunk/reactos/dll/win32/winhttp/session.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/session.c [iso-8859-1] Sun Sep 24 11:17:43 2017 @@ -685,7 +685,7 @@ { case WINHTTP_OPTION_SECURITY_FLAGS: { - DWORD flags; + DWORD flags = 0; int bits; if (!buffer || *buflen < sizeof(flags)) @@ -697,14 +697,17 @@ flags = 0; if (hdr->flags & WINHTTP_FLAG_SECURE) flags |= SECURITY_FLAG_SECURE; - flags |= request->netconn.security_flags; - bits = netconn_get_cipher_strength( &request->netconn ); - if (bits >= 128) - flags |= SECURITY_FLAG_STRENGTH_STRONG; - else if (bits >= 56) - flags |= SECURITY_FLAG_STRENGTH_MEDIUM; - else - flags |= SECURITY_FLAG_STRENGTH_WEAK; + flags |= request->security_flags; + if (request->netconn) + { + bits = netconn_get_cipher_strength( request->netconn ); + if (bits >= 128) + flags |= SECURITY_FLAG_STRENGTH_STRONG; + else if (bits >= 56) + flags |= SECURITY_FLAG_STRENGTH_MEDIUM; + else + flags |= SECURITY_FLAG_STRENGTH_WEAK; + } *(DWORD *)buffer = flags; *buflen = sizeof(flags); return TRUE; @@ -720,7 +723,7 @@ return FALSE; } - if (!(cert = netconn_get_certificate( &request->netconn ))) return FALSE; + if (!request->netconn || !(cert = netconn_get_certificate( request->netconn ))) return FALSE; *(CERT_CONTEXT **)buffer = (CERT_CONTEXT *)cert; *buflen = sizeof(cert); return TRUE; @@ -739,7 +742,7 @@ set_last_error( ERROR_INSUFFICIENT_BUFFER ); return FALSE; } - if (!(cert = netconn_get_certificate( &request->netconn ))) return FALSE; + if (!request->netconn || !(cert = netconn_get_certificate( request->netconn ))) return FALSE; ci->ftExpiry = cert->pCertInfo->NotAfter; ci->ftStart = cert->pCertInfo->NotBefore; @@ -754,7 +757,7 @@ else ci->lpszSignatureAlgName = NULL; ci->lpszEncryptionAlgName = NULL; - ci->dwKeySize = netconn_get_cipher_strength( &request->netconn ); + ci->dwKeySize = request->netconn ? netconn_get_cipher_strength( request->netconn ) : 0; CertFreeCertificateContext( cert ); *buflen = sizeof(*ci); @@ -769,7 +772,7 @@ return FALSE; } - *(DWORD *)buffer = netconn_get_cipher_strength( &request->netconn ); + *(DWORD *)buffer = request->netconn ? netconn_get_cipher_strength( request->netconn ) : 0; *buflen = sizeof(DWORD); return TRUE; } @@ -786,12 +789,12 @@ set_last_error( ERROR_INSUFFICIENT_BUFFER ); return FALSE; } - if (!netconn_connected( &request->netconn )) + if (!request->netconn) { set_last_error( ERROR_WINHTTP_INCORRECT_HANDLE_STATE ); return FALSE; } - if (getsockname( request->netconn.socket, &local, &len )) return FALSE; + if (getsockname( request->netconn->socket, &local, &len )) return FALSE; if (!convert_sockaddr( &local, &info->LocalAddress )) return FALSE; if (!convert_sockaddr( remote, &info->RemoteAddress )) return FALSE; info->cbSize = sizeof(*info); @@ -927,7 +930,7 @@ set_last_error( ERROR_INVALID_PARAMETER ); return FALSE; } - request->netconn.security_flags = flags; + request->security_flags = flags; return TRUE; } case WINHTTP_OPTION_RESOLVE_TIMEOUT: @@ -1064,7 +1067,6 @@ request->connect = connect; list_add_head( &connect->hdr.children, &request->hdr.entry ); - if (!netconn_init( &request->netconn )) goto end; request->resolve_timeout = connect->session->resolve_timeout; request->connect_timeout = connect->session->connect_timeout; request->send_timeout = connect->session->send_timeout; @@ -2047,10 +2049,10 @@ if (receive < 0) receive = 0; request->recv_timeout = receive; - if (netconn_connected( &request->netconn )) + if (request->netconn) { - if (netconn_set_timeout( &request->netconn, TRUE, send )) ret = FALSE; - if (netconn_set_timeout( &request->netconn, FALSE, receive )) ret = FALSE; + if (netconn_set_timeout( request->netconn, TRUE, send )) ret = FALSE; + if (netconn_set_timeout( request->netconn, FALSE, receive )) ret = FALSE; } break; Modified: trunk/reactos/dll/win32/winhttp/winhttp_private.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winhttp/winhttp_…
============================================================================== --- trunk/reactos/dll/win32/winhttp/winhttp_private.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winhttp/winhttp_private.h [iso-8859-1] Sun Sep 24 11:17:43 2017 @@ -111,6 +111,15 @@ WCHAR *path; } cookie_t; +typedef struct { + struct list entry; + LONG ref; + WCHAR *hostname; + INTERNET_PORT port; + BOOL secure; + struct list connections; +} hostdata_t; + typedef struct { object_header_t hdr; @@ -144,8 +153,12 @@ typedef struct { + struct list entry; int socket; + struct sockaddr_storage sockaddr; BOOL secure; /* SSL active on connection? */ + hostdata_t *host; + ULONGLONG keep_until; CtxtHandle ssl_ctx; SecPkgContext_StreamSizes ssl_sizes; char *ssl_buf; @@ -154,7 +167,6 @@ char *peek_msg; char *peek_msg_mem; size_t peek_len; - DWORD security_flags; } netconn_t; typedef struct @@ -206,7 +218,8 @@ LPWSTR raw_headers; void *optional; DWORD optional_len; - netconn_t netconn; + netconn_t *netconn; + DWORD security_flags; int resolve_timeout; int connect_timeout; int send_timeout; @@ -295,17 +308,15 @@ void close_connection( request_t * ) DECLSPEC_HIDDEN; BOOL netconn_close( netconn_t * ) DECLSPEC_HIDDEN; -BOOL netconn_connect( netconn_t *, const struct sockaddr *, unsigned int, int ) DECLSPEC_HIDDEN; -BOOL netconn_connected( netconn_t * ) DECLSPEC_HIDDEN; -BOOL netconn_create( netconn_t *, int, int, int ) DECLSPEC_HIDDEN; -BOOL netconn_init( netconn_t * ) DECLSPEC_HIDDEN; +netconn_t *netconn_create( hostdata_t *, const struct sockaddr_storage *, int ) DECLSPEC_HIDDEN; void netconn_unload( void ) DECLSPEC_HIDDEN; ULONG netconn_query_data_available( netconn_t * ) DECLSPEC_HIDDEN; BOOL netconn_recv( netconn_t *, void *, size_t, int, int * ) DECLSPEC_HIDDEN; -BOOL netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr *, socklen_t *, int ) DECLSPEC_HIDDEN; -BOOL netconn_secure_connect( netconn_t *, WCHAR * ) DECLSPEC_HIDDEN; +BOOL netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int ) DECLSPEC_HIDDEN; +BOOL netconn_secure_connect( netconn_t *, WCHAR *, DWORD ) DECLSPEC_HIDDEN; BOOL netconn_send( netconn_t *, const void *, size_t, int * ) DECLSPEC_HIDDEN; DWORD netconn_set_timeout( netconn_t *, BOOL, int ) DECLSPEC_HIDDEN; +BOOL netconn_is_alive( netconn_t * ) DECLSPEC_HIDDEN; const void *netconn_get_certificate( netconn_t * ) DECLSPEC_HIDDEN; int netconn_get_cipher_strength( netconn_t * ) DECLSPEC_HIDDEN; @@ -315,6 +326,8 @@ void delete_domain( domain_t * ) DECLSPEC_HIDDEN; BOOL set_server_for_hostname( connect_t *, LPCWSTR, INTERNET_PORT ) DECLSPEC_HIDDEN; void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN; + +void release_host( hostdata_t *host ) DECLSPEC_HIDDEN; BOOL process_header( request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only ) DECLSPEC_HIDDEN; @@ -395,4 +408,6 @@ return dst; } +extern HINSTANCE winhttp_instance DECLSPEC_HIDDEN; + #endif /* _WINE_WINHTTP_PRIVATE_H_ */ Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Sep 24 11:17:43 2017 @@ -200,7 +200,7 @@ reactos/dll/win32/windowscodecsext # Synced to WineStaging-2.9 reactos/dll/win32/winemp3.acm # Synced to WineStaging-2.16 reactos/dll/win32/wing32 # Synced to WineStaging-2.9 -reactos/dll/win32/winhttp # Synced to WineStaging-2.9 +reactos/dll/win32/winhttp # Synced to WineStaging-2.16 reactos/dll/win32/wininet # Synced to WineStaging-2.9 reactos/dll/win32/winmm # Forked at Wine-20050628 reactos/dll/win32/winmm/midimap # Forked at Wine-20050628
7 years, 3 months
1
0
0
0
[akhaldi] 75943: [WINEMP3.ACM] Sync with Wine Staging 2.16. CORE-13762 ffebb91 winemp3.acm: Fix error in acmStreamSize().
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:17:34 2017 New Revision: 75943 URL:
http://svn.reactos.org/svn/reactos?rev=75943&view=rev
Log: [WINEMP3.ACM] Sync with Wine Staging 2.16. CORE-13762 ffebb91 winemp3.acm: Fix error in acmStreamSize(). Modified: trunk/reactos/dll/win32/winemp3.acm/mpegl3.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/winemp3.acm/mpegl3.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winemp3.acm/mpeg…
============================================================================== --- trunk/reactos/dll/win32/winemp3.acm/mpegl3.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winemp3.acm/mpegl3.c [iso-8859-1] Sun Sep 24 11:17:34 2017 @@ -953,11 +953,11 @@ adsi->pwfxDst->wFormatTag == WAVE_FORMAT_MPEG)) { nblocks = adss->cbSrcLength / (adsi->pwfxSrc->nBlockAlign * 1152); - if (nblocks == 0) - return ACMERR_NOTPOSSIBLE; if (adss->cbSrcLength % (DWORD)(adsi->pwfxSrc->nBlockAlign * 1152)) /* Round block count up. */ nblocks++; + if (nblocks == 0) + return ACMERR_NOTPOSSIBLE; adss->cbDstLength = 3000 + nblocks * (DWORD)(adsi->pwfxDst->nAvgBytesPerSec * 1152 / adsi->pwfxDst->nSamplesPerSec + 0.5); } else if ((adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_MPEGLAYER3 || @@ -965,11 +965,11 @@ adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM) { nblocks = adss->cbSrcLength / (DWORD)(adsi->pwfxSrc->nAvgBytesPerSec * 1152 / adsi->pwfxSrc->nSamplesPerSec); - if (nblocks == 0) - return ACMERR_NOTPOSSIBLE; if (adss->cbSrcLength % (DWORD)(adsi->pwfxSrc->nAvgBytesPerSec * 1152 / adsi->pwfxSrc->nSamplesPerSec)) /* Round block count up. */ nblocks++; + if (nblocks == 0) + return ACMERR_NOTPOSSIBLE; adss->cbDstLength = nblocks * 1152 * adsi->pwfxDst->nBlockAlign; } else Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Sep 24 11:17:34 2017 @@ -198,7 +198,7 @@ reactos/dll/win32/wbemprox # Synced to WineStaging-2.16 reactos/dll/win32/windowscodecs # Synced to WineStaging-2.9 reactos/dll/win32/windowscodecsext # Synced to WineStaging-2.9 -reactos/dll/win32/winemp3.acm # Synced to WineStaging-2.9 +reactos/dll/win32/winemp3.acm # Synced to WineStaging-2.16 reactos/dll/win32/wing32 # Synced to WineStaging-2.9 reactos/dll/win32/winhttp # Synced to WineStaging-2.9 reactos/dll/win32/wininet # Synced to WineStaging-2.9
7 years, 3 months
1
0
0
0
[akhaldi] 75942: [WBEMPROX] Sync with Wine Staging 2.16. CORE-13762 65d7ff8 wbemprox: Add FreePhysicalMemory to Win32_OperatingSystem.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:17:27 2017 New Revision: 75942 URL:
http://svn.reactos.org/svn/reactos?rev=75942&view=rev
Log: [WBEMPROX] Sync with Wine Staging 2.16. CORE-13762 65d7ff8 wbemprox: Add FreePhysicalMemory to Win32_OperatingSystem. Modified: trunk/reactos/dll/win32/wbemprox/builtin.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/wbemprox/builtin.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wbemprox/builtin…
============================================================================== --- trunk/reactos/dll/win32/wbemprox/builtin.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wbemprox/builtin.c [iso-8859-1] Sun Sep 24 11:17:27 2017 @@ -196,6 +196,8 @@ {'F','l','a','v','o','r',0}; static const WCHAR prop_freespaceW[] = {'F','r','e','e','S','p','a','c','e',0}; +static const WCHAR prop_freephysicalmemoryW[] = + {'F','r','e','e','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0}; static const WCHAR prop_handleW[] = {'H','a','n','d','l','e',0}; static const WCHAR prop_horizontalresolutionW[] = @@ -530,6 +532,7 @@ { prop_systemdirectoryW, CIM_STRING|COL_FLAG_DYNAMIC }, { prop_totalvirtualmemorysizeW, CIM_UINT64 }, { prop_totalvisiblememorysizeW, CIM_UINT64 }, + { prop_freephysicalmemoryW, CIM_UINT64 }, { prop_versionW, CIM_STRING|COL_FLAG_DYNAMIC } }; static const struct column col_param[] = @@ -934,6 +937,7 @@ const WCHAR *systemdirectory; UINT64 totalvirtualmemorysize; UINT64 totalvisiblememorysize; + UINT64 freephysicalmemory; const WCHAR *version; }; struct record_param @@ -1305,6 +1309,15 @@ status.dwLength = sizeof(status); if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024; return status.ullTotalPhys; +} + +static UINT64 get_available_physical_memory(void) +{ + MEMORYSTATUSEX status; + + status.dwLength = sizeof(status); + if (!GlobalMemoryStatusEx( &status )) return 1024 * 1024 * 1024; + return status.ullAvailPhys; } static WCHAR *get_computername(void) @@ -2897,6 +2910,7 @@ rec->systemdirectory = get_systemdirectory(); rec->totalvirtualmemorysize = get_total_physical_memory() / 1024; rec->totalvisiblememorysize = rec->totalvirtualmemorysize; + rec->freephysicalmemory = get_available_physical_memory() / 1024; rec->version = get_osversion( &ver ); if (!match_row( table, row, cond, &status )) free_row_values( table, row ); else row++; Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Sep 24 11:17:27 2017 @@ -195,7 +195,7 @@ reactos/dll/win32/version # Synced to WineStaging-2.9 reactos/dll/win32/vssapi # Synced to WineStaging-2.9 reactos/dll/win32/wbemdisp # Synced to WineStaging-2.16 -reactos/dll/win32/wbemprox # Synced to WineStaging-2.9 +reactos/dll/win32/wbemprox # Synced to WineStaging-2.16 reactos/dll/win32/windowscodecs # Synced to WineStaging-2.9 reactos/dll/win32/windowscodecsext # Synced to WineStaging-2.9 reactos/dll/win32/winemp3.acm # Synced to WineStaging-2.9
7 years, 3 months
1
0
0
0
[akhaldi] 75941: [WBEMDISP] Sync with Wine Staging 2.16. CORE-13762 82527f8 wbemdisp: Add a trailing newline to a TRACE() message.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Sun Sep 24 11:17:20 2017 New Revision: 75941 URL:
http://svn.reactos.org/svn/reactos?rev=75941&view=rev
Log: [WBEMDISP] Sync with Wine Staging 2.16. CORE-13762 82527f8 wbemdisp: Add a trailing newline to a TRACE() message. Modified: trunk/reactos/dll/win32/wbemdisp/locator.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/wbemdisp/locator.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wbemdisp/locator…
============================================================================== --- trunk/reactos/dll/win32/wbemdisp/locator.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wbemdisp/locator.c [iso-8859-1] Sun Sep 24 11:17:20 2017 @@ -408,7 +408,7 @@ HRESULT hr; VARIANT var; - TRACE( "%p, %s, %08x, %p", propertyset, debugstr_w(name), flags, prop ); + TRACE( "%p, %s, %08x, %p\n", propertyset, debugstr_w(name), flags, prop ); hr = IWbemClassObject_Get( propertyset->object, name, 0, &var, NULL, NULL ); if (SUCCEEDED(hr)) Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Sep 24 11:17:20 2017 @@ -194,7 +194,7 @@ reactos/dll/win32/vbscript # Synced to WineStaging-2.9 reactos/dll/win32/version # Synced to WineStaging-2.9 reactos/dll/win32/vssapi # Synced to WineStaging-2.9 -reactos/dll/win32/wbemdisp # Synced to WineStaging-2.9 +reactos/dll/win32/wbemdisp # Synced to WineStaging-2.16 reactos/dll/win32/wbemprox # Synced to WineStaging-2.9 reactos/dll/win32/windowscodecs # Synced to WineStaging-2.9 reactos/dll/win32/windowscodecsext # Synced to WineStaging-2.9
7 years, 3 months
1
0
0
0
← Newer
1
...
4
5
6
7
8
9
10
...
29
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Results per page:
10
25
50
100
200