Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(748)

Side by Side Diff: chrome/test/webdriver/http_response.h

Issue 10827362: Fix ChromeDriver flakiness with the C# webdriver bindings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/webdriver/http_response.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_TEST_WEBDRIVER_HTTP_RESPONSE_H_ 5 #ifndef CHROME_TEST_WEBDRIVER_HTTP_RESPONSE_H_
6 #define CHROME_TEST_WEBDRIVER_HTTP_RESPONSE_H_ 6 #define CHROME_TEST_WEBDRIVER_HTTP_RESPONSE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 12
13 namespace webdriver { 13 namespace webdriver {
14 14
15 class HttpResponse { 15 class HttpResponse {
16 public: 16 public:
17 typedef std::map<std::string, std::string> HeaderMap; 17 typedef std::map<std::string, std::string> HeaderMap;
18 18
19 // The supported HTTP response codes. 19 // The supported HTTP response codes.
20 static const int kOk; 20 static const int kOk;
21 static const int kNoContent; 21 static const int kNoContent;
22 static const int kSeeOther; 22 static const int kSeeOther;
23 static const int kNotModified; 23 static const int kNotModified;
24 static const int kBadRequest; 24 static const int kBadRequest;
25 static const int kForbidden;
25 static const int kNotFound; 26 static const int kNotFound;
26 static const int kMethodNotAllowed; 27 static const int kMethodNotAllowed;
27 static const int kInternalServerError; 28 static const int kInternalServerError;
29 static const int kNotImplemented;
28 30
31 // Creates an HTTP response with a 200 OK status.
29 HttpResponse(); 32 HttpResponse();
33 explicit HttpResponse(int status);
30 ~HttpResponse(); 34 ~HttpResponse();
31 35
32 // Sets a header in this response. If a header with the same |name| already 36 // Sets a header in this response. If a header with the same |name| already
33 // exists, the |value| will be appended to the existing values. Since header 37 // exists, the |value| will be appended to the existing values. Since header
34 // names are case insensitive, the header will be stored in lowercase format. 38 // names are case insensitive, the header will be stored in lowercase format.
35 void AddHeader(const std::string& name, const std::string& value); 39 void AddHeader(const std::string& name, const std::string& value);
36 40
37 // Retrieves the value of the specified header. If there is no such header, 41 // Retrieves the value of the specified header. If there is no such header,
38 // the output |value| will not be modified and false will be returned. 42 // the output |value| will not be modified and false will be returned.
39 bool GetHeader(const std::string& name, std::string* value) const; 43 bool GetHeader(const std::string& name, std::string* value) const;
40 44
41 // Removes the header with the given |name|. Returns whether there was a 45 // Removes the header with the given |name|. Returns whether there was a
42 // matching header to remove. 46 // matching header to remove.
43 bool RemoveHeader(const std::string& name); 47 bool RemoveHeader(const std::string& name);
44 48
45 // Removes all headers. 49 // Removes all headers.
46 void ClearHeaders(); 50 void ClearHeaders();
47 51
48 // Convenience function for setting the Content-Type header for this response. 52 // Convenience function for setting the Content-Type header for this response.
49 void SetMimeType(const std::string& mime_type); 53 void SetMimeType(const std::string& mime_type);
50 54
51 // Sets the message body for this response; will also set the "Content-Length"
52 // message header.
53 void SetBody(const std::string& data);
54 void SetBody(const char* const data, size_t length);
55
56 // Returns the status phrase recommended by RFC 2616 section 6.1.1 for this 55 // Returns the status phrase recommended by RFC 2616 section 6.1.1 for this
57 // response's status code. If the status code is not recognized, the default 56 // response's status code. If the status code is not recognized, the default
58 // "Unknown" status phrase will be used. 57 // "Unknown" status phrase will be used.
59 std::string GetReasonPhrase() const; 58 std::string GetReasonPhrase() const;
60 59
60 // Appends this response to |data|, abiding by HTTP 1.1.
61 // This will add an appropriate "Content-Length" header if not already set.
62 void GetData(std::string* data) const;
63
61 int status() const; 64 int status() const;
62 void set_status(int status); 65 void set_status(int status);
63 const HeaderMap* headers() const; 66 const std::string& body() const;
64 const char* data() const; 67 void set_body(const std::string& body);
65 size_t length() const;
66 68
67 private: 69 private:
68 void UpdateHeader(const std::string& name, const std::string& new_value); 70 void UpdateHeader(const std::string& name, const std::string& new_value);
69 71
70 int status_; 72 int status_;
71 HeaderMap headers_; 73 HeaderMap headers_;
72 std::string data_; 74 std::string body_;
73
74 DISALLOW_COPY_AND_ASSIGN(HttpResponse);
75 }; 75 };
76 76
77 } // webdriver 77 } // webdriver
78 78
79 #endif // CHROME_TEST_WEBDRIVER_HTTP_RESPONSE_H_ 79 #endif // CHROME_TEST_WEBDRIVER_HTTP_RESPONSE_H_
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/test/webdriver/http_response.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698