1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 #include "public/platform/WebURLError.h"
9 #include "public/platform/WebURLResponse.h"
10 #include "wtf/text/WTFString.h"
16 class WebURLLoaderClient
;
18 // Simulates a single request for a resource from the server. Requires a
19 // SimNetwork to have been created first. Use the start(), write() and finish()
20 // methods to simulate the response from the server. Note that all started
21 // requests must be finished.
22 class SimRequest final
{
24 SimRequest(String url
, String mimeType
);
27 // Starts the response from the server, this is as if the headers and 200 OK
28 // reply had been received but no response body yet.
31 // Write a chunk of the response body.
32 void write(const String
& data
);
34 // Finish the response, this is as if the server closed the connection.
37 const String
& url() const { return m_url
; }
38 const WebURLError
& error() const { return m_error
; }
39 const WebURLResponse
& response() const { return m_response
; }
42 friend class SimNetwork
;
46 // Used by SimNetwork.
47 void didReceiveResponse(WebURLLoaderClient
*, WebURLLoader
*, const WebURLResponse
&);
48 void didFail(const WebURLError
&);
51 WebURLLoader
* m_loader
;
52 WebURLResponse m_response
;
54 WebURLLoaderClient
* m_client
;
55 unsigned m_totalEncodedDataLength
;