urlmon: Move close_connection implementation to common Protocol object.
This commit is contained in:
parent
7c77c57ab8
commit
a30ffca108
|
@ -80,9 +80,32 @@ typedef struct {
|
||||||
static const WCHAR wszHeaders[] = {'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',
|
static const WCHAR wszHeaders[] = {'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',
|
||||||
':',' ','g','z','i','p',',',' ','d','e','f','l','a','t','e',0};
|
':',' ','g','z','i','p',',',' ','d','e','f','l','a','t','e',0};
|
||||||
|
|
||||||
/*
|
#define ASYNCPROTOCOL_THIS(iface) DEFINE_THIS2(HttpProtocol, base, iface)
|
||||||
* Helpers
|
|
||||||
*/
|
static void HttpProtocol_close_connection(Protocol *prot)
|
||||||
|
{
|
||||||
|
HttpProtocol *This = ASYNCPROTOCOL_THIS(prot);
|
||||||
|
|
||||||
|
if(This->connection)
|
||||||
|
InternetCloseHandle(This->connection);
|
||||||
|
|
||||||
|
if(This->http_negotiate) {
|
||||||
|
IHttpNegotiate_Release(This->http_negotiate);
|
||||||
|
This->http_negotiate = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(This->full_header) {
|
||||||
|
if(This->full_header != wszHeaders)
|
||||||
|
heap_free(This->full_header);
|
||||||
|
This->full_header = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef ASYNCPROTOCOL_THIS
|
||||||
|
|
||||||
|
static const ProtocolVtbl AsyncProtocolVtbl = {
|
||||||
|
HttpProtocol_close_connection
|
||||||
|
};
|
||||||
|
|
||||||
static void HTTPPROTOCOL_ReportResult(HttpProtocol *This, HRESULT hres)
|
static void HTTPPROTOCOL_ReportResult(HttpProtocol *This, HRESULT hres)
|
||||||
{
|
{
|
||||||
|
@ -129,31 +152,6 @@ static void HTTPPROTOCOL_AllDataRead(HttpProtocol *This)
|
||||||
HTTPPROTOCOL_ReportResult(This, S_OK);
|
HTTPPROTOCOL_ReportResult(This, S_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HTTPPROTOCOL_Close(HttpProtocol *This)
|
|
||||||
{
|
|
||||||
if (This->http_negotiate)
|
|
||||||
{
|
|
||||||
IHttpNegotiate_Release(This->http_negotiate);
|
|
||||||
This->http_negotiate = 0;
|
|
||||||
}
|
|
||||||
if (This->base.request)
|
|
||||||
InternetCloseHandle(This->base.request);
|
|
||||||
if (This->connection)
|
|
||||||
InternetCloseHandle(This->connection);
|
|
||||||
if (This->base.internet)
|
|
||||||
{
|
|
||||||
InternetCloseHandle(This->base.internet);
|
|
||||||
This->base.internet = 0;
|
|
||||||
}
|
|
||||||
if (This->full_header)
|
|
||||||
{
|
|
||||||
if (This->full_header != wszHeaders)
|
|
||||||
heap_free(This->full_header);
|
|
||||||
This->full_header = 0;
|
|
||||||
}
|
|
||||||
This->base.flags = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void CALLBACK HTTPPROTOCOL_InternetStatusCallback(
|
static void CALLBACK HTTPPROTOCOL_InternetStatusCallback(
|
||||||
HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus,
|
HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus,
|
||||||
LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
|
LPVOID lpvStatusInformation, DWORD dwStatusInformationLength)
|
||||||
|
@ -269,7 +267,7 @@ static ULONG WINAPI HttpProtocol_Release(IInternetProtocol *iface)
|
||||||
TRACE("(%p) ref=%d\n", This, ref);
|
TRACE("(%p) ref=%d\n", This, ref);
|
||||||
|
|
||||||
if(!ref) {
|
if(!ref) {
|
||||||
HTTPPROTOCOL_Close(This);
|
protocol_close_connection(&This->base);
|
||||||
heap_free(This);
|
heap_free(This);
|
||||||
|
|
||||||
URLMON_UnlockModule();
|
URLMON_UnlockModule();
|
||||||
|
@ -523,7 +521,7 @@ done:
|
||||||
if (hres != S_OK)
|
if (hres != S_OK)
|
||||||
{
|
{
|
||||||
IInternetProtocolSink_ReportResult(This->base.protocol_sink, hres, 0, NULL);
|
IInternetProtocolSink_ReportResult(This->base.protocol_sink, hres, 0, NULL);
|
||||||
HTTPPROTOCOL_Close(This);
|
protocol_close_connection(&This->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
CoTaskMemFree(post_cookie);
|
CoTaskMemFree(post_cookie);
|
||||||
|
@ -714,8 +712,8 @@ static HRESULT WINAPI HttpProtocol_Terminate(IInternetProtocol *iface, DWORD dwO
|
||||||
HttpProtocol *This = PROTOCOL_THIS(iface);
|
HttpProtocol *This = PROTOCOL_THIS(iface);
|
||||||
|
|
||||||
TRACE("(%p)->(%08x)\n", This, dwOptions);
|
TRACE("(%p)->(%08x)\n", This, dwOptions);
|
||||||
HTTPPROTOCOL_Close(This);
|
|
||||||
|
|
||||||
|
protocol_close_connection(&This->base);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -915,6 +913,7 @@ static HRESULT create_http_protocol(BOOL https, void **ppobj)
|
||||||
if(!ret)
|
if(!ret)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
ret->base.vtbl = &AsyncProtocolVtbl;
|
||||||
ret->lpInternetProtocolVtbl = &HttpProtocolVtbl;
|
ret->lpInternetProtocolVtbl = &HttpProtocolVtbl;
|
||||||
ret->lpInternetPriorityVtbl = &HttpPriorityVtbl;
|
ret->lpInternetPriorityVtbl = &HttpPriorityVtbl;
|
||||||
|
|
||||||
|
|
|
@ -42,3 +42,17 @@ HRESULT protocol_unlock_request(Protocol *protocol)
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void protocol_close_connection(Protocol *protocol)
|
||||||
|
{
|
||||||
|
protocol->vtbl->close_connection(protocol);
|
||||||
|
|
||||||
|
if(protocol->request)
|
||||||
|
InternetCloseHandle(protocol->request);
|
||||||
|
if(protocol->internet) {
|
||||||
|
InternetCloseHandle(protocol->internet);
|
||||||
|
protocol->internet = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protocol->flags = 0;
|
||||||
|
}
|
||||||
|
|
|
@ -79,7 +79,11 @@ HRESULT bind_to_object(IMoniker *mon, LPCWSTR url, IBindCtx *pbc, REFIID riid, v
|
||||||
HRESULT create_binding_protocol(LPCWSTR url, BOOL from_urlmon, IInternetProtocol **protocol);
|
HRESULT create_binding_protocol(LPCWSTR url, BOOL from_urlmon, IInternetProtocol **protocol);
|
||||||
void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink);
|
void set_binding_sink(IInternetProtocol *bind_protocol, IInternetProtocolSink *sink);
|
||||||
|
|
||||||
|
typedef struct ProtocolVtbl ProtocolVtbl;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
const ProtocolVtbl *vtbl;
|
||||||
|
|
||||||
IInternetProtocol *protocol;
|
IInternetProtocol *protocol;
|
||||||
IInternetProtocolSink *protocol_sink;
|
IInternetProtocolSink *protocol_sink;
|
||||||
|
|
||||||
|
@ -98,8 +102,13 @@ typedef struct {
|
||||||
LONG priority;
|
LONG priority;
|
||||||
} Protocol;
|
} Protocol;
|
||||||
|
|
||||||
|
struct ProtocolVtbl {
|
||||||
|
void (*close_connection)(Protocol*);
|
||||||
|
};
|
||||||
|
|
||||||
HRESULT protocol_lock_request(Protocol*);
|
HRESULT protocol_lock_request(Protocol*);
|
||||||
HRESULT protocol_unlock_request(Protocol*);
|
HRESULT protocol_unlock_request(Protocol*);
|
||||||
|
void protocol_close_connection(Protocol*);
|
||||||
|
|
||||||
static inline void *heap_alloc(size_t len)
|
static inline void *heap_alloc(size_t len)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue