| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2011 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "platform/network/HTTPRequest.h" | 27 #include "platform/network/HTTPRequest.h" |
| 28 | 28 |
| 29 #include "wtf/text/CString.h" | 29 #include "wtf/text/CString.h" |
| 30 | 30 |
| 31 namespace WebCore { | 31 namespace WebCore { |
| 32 | 32 |
| 33 PassRefPtr<HTTPRequest> HTTPRequest::parseHTTPRequestFromBuffer(const char* data
, size_t length, String& failureReason) | 33 PassRefPtr<HTTPRequest> HTTPRequest::parseHTTPRequestFromBuffer(const char* data
, size_t length, String& failureReason) |
| 34 { | 34 { |
| 35 if (!length) { | 35 if (!length) { |
| 36 failureReason = "No data to parse."; | 36 failureReason = "No data to parse."; |
| 37 return 0; | 37 return nullptr; |
| 38 } | 38 } |
| 39 | 39 |
| 40 // Request we will be building. | 40 // Request we will be building. |
| 41 RefPtr<HTTPRequest> request = HTTPRequest::create(); | 41 RefPtr<HTTPRequest> request = HTTPRequest::create(); |
| 42 | 42 |
| 43 // Advance a pointer through the data as needed. | 43 // Advance a pointer through the data as needed. |
| 44 const char* pos = data; | 44 const char* pos = data; |
| 45 size_t remainingLength = length; | 45 size_t remainingLength = length; |
| 46 | 46 |
| 47 // 1. Parse Method + URL. | 47 // 1. Parse Method + URL. |
| 48 size_t requestLineLength = request->parseRequestLine(pos, remainingLength, f
ailureReason); | 48 size_t requestLineLength = request->parseRequestLine(pos, remainingLength, f
ailureReason); |
| 49 if (!requestLineLength) | 49 if (!requestLineLength) |
| 50 return 0; | 50 return nullptr; |
| 51 pos += requestLineLength; | 51 pos += requestLineLength; |
| 52 remainingLength -= requestLineLength; | 52 remainingLength -= requestLineLength; |
| 53 | 53 |
| 54 // 2. Parse HTTP Headers. | 54 // 2. Parse HTTP Headers. |
| 55 size_t headersLength = request->parseHeaders(pos, remainingLength, failureRe
ason); | 55 size_t headersLength = request->parseHeaders(pos, remainingLength, failureRe
ason); |
| 56 if (!headersLength) | 56 if (!headersLength) |
| 57 return 0; | 57 return nullptr; |
| 58 pos += headersLength; | 58 pos += headersLength; |
| 59 remainingLength -= headersLength; | 59 remainingLength -= headersLength; |
| 60 | 60 |
| 61 // 3. Parse HTTP Data. | 61 // 3. Parse HTTP Data. |
| 62 size_t dataLength = request->parseRequestBody(pos, remainingLength); | 62 size_t dataLength = request->parseRequestBody(pos, remainingLength); |
| 63 remainingLength -= dataLength; | 63 remainingLength -= dataLength; |
| 64 | 64 |
| 65 // We should have processed the entire input. | 65 // We should have processed the entire input. |
| 66 ASSERT(!remainingLength); | 66 ASSERT(!remainingLength); |
| 67 return request.release(); | 67 return request.release(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 , m_httpVersion(version) | 108 , m_httpVersion(version) |
| 109 , m_requestMethod(requestMethod) | 109 , m_requestMethod(requestMethod) |
| 110 { | 110 { |
| 111 } | 111 } |
| 112 | 112 |
| 113 HTTPRequest::~HTTPRequest() | 113 HTTPRequest::~HTTPRequest() |
| 114 { | 114 { |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace WebCore | 117 } // namespace WebCore |
| OLD | NEW |