HTTP 응답의 헤더에 대한 속성/값 맵을 반환합니다. 여러 값이 있는 헤더는 배열로 반환됩니다.
// The code below logs the HTTP headers from the response// received when fetching the Google home page.constresponse=UrlFetchApp.fetch('http://www.google.com/');Logger.log(response.getAllHeaders());
리턴
Object - HTTP 헤더의 JavaScript 키/값 맵
getAs(contentType)
이 객체 내의 데이터를 지정된 콘텐츠 유형으로 변환된 blob으로 반환합니다. 이 메서드는 파일 이름에 적절한 확장자(예: 'myfile.pdf')를 추가합니다. 하지만 마지막 마침표 뒤에 오는 파일 이름 부분이 대체해야 하는 기존 확장 프로그램이라고 가정합니다. 따라서 'ShoppingList.12.25.2014'는 'ShoppingList.12.25.pdf'가 됩니다.
전환의 일일 할당량을 보려면 Google 서비스 할당량을 참고하세요. 새로 생성된 Google Workspace 도메인에는 일시적으로 더 엄격한 할당량이 적용될 수 있습니다.
매개변수
이름
유형
설명
contentType
String
변환할 MIME 유형입니다. 대부분의 블롭의 경우 'application/pdf'만 사용할 수 있습니다. BMP, GIF, JPEG 또는 PNG 형식의 이미지의 경우 'image/bmp', 'image/gif', 'image/jpeg' 또는 'image/png'도 유효합니다. Google Docs 문서의 경우 'text/markdown'도 유효합니다.
// The code below logs the value of the first byte of the Google home page.constresponse=UrlFetchApp.fetch('http://www.google.com/');Logger.log(response.getContent()[0]);
리턴
Byte[] - 콘텐츠(원시 바이너리 배열)
getContentText()
문자열로 인코딩된 HTTP 응답의 콘텐츠를 가져옵니다.
// The code below logs the HTML code of the Google home page.constresponse=UrlFetchApp.fetch('http://www.google.com/');Logger.log(response.getContentText());
리턴
String: HTTP 응답의 콘텐츠(문자열)
getContentText(charset)
지정된 문자 집합으로 인코딩된 HTTP 응답의 콘텐츠를 반환합니다.
// The code below logs the HTML code of the Google home page with the UTF-8// charset.constresponse=UrlFetchApp.fetch('http://www.google.com/');Logger.log(response.getContentText('UTF-8'));
매개변수
이름
유형
설명
charset
String
HTTP 응답 콘텐츠를 인코딩하는 데 사용할 문자 집합을 나타내는 문자열
리턴
String - 지정된 문자 집합을 사용하여 인코딩된 HTTP 응답의 콘텐츠
getHeaders()
HTTP 응답의 헤더 속성/값 맵을 반환합니다.
// The code below logs the HTTP headers from the response// received when fetching the Google home page.constresponse=UrlFetchApp.fetch('http://www.google.com/');Logger.log(response.getHeaders());
리턴
Object - HTTP 헤더의 JavaScript 키/값 맵
getResponseCode()
HTTP 응답의 HTTP 상태 코드 (OK의 경우 200 등)를 가져옵니다.
// The code below logs the HTTP status code from the response received// when fetching the Google home page.// It should be 200 if the request succeeded.constresponse=UrlFetchApp.fetch('http://www.google.com/');Logger.log(response.getResponseCode());
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-08(UTC)"],[[["\u003cp\u003eThe \u003ccode\u003eHTTPResponse\u003c/code\u003e class provides access to data and metadata returned from an HTTP request made by \u003ccode\u003eUrlFetchApp\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt offers methods to retrieve content as raw bytes, string, or blob, and to get headers or the response code.\u003c/p\u003e\n"],["\u003cp\u003eContent can be retrieved in various formats, including blob and string, with options for content type conversion.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can access HTTP headers to get detailed response information for debugging or further processing.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eHTTPResponse\u003c/code\u003e helps developers work with HTTP responses received by \u003ccode\u003eUrlFetchApp\u003c/code\u003e within Apps Script.\u003c/p\u003e\n"]]],[],null,["HTTPResponse\n\nThis class allows users to access specific information on HTTP responses.\n\nSee also\n\n- [UrlFetchApp](/apps-script/reference/url-fetch/url-fetch-app) \n\nMethods\n\n| Method | Return type | Brief description |\n|----------------------------------------------------|---------------------------|-----------------------------------------------------------------------------------------------------------------------------|\n| [getAllHeaders()](#getAllHeaders()) | `Object` | Returns an attribute/value map of headers for the HTTP response, with headers that have multiple values returned as arrays. |\n| [getAs(contentType)](#getAs(String)) | [Blob](../base/blob.html) | Return the data inside this object as a blob converted to the specified content type. |\n| [getBlob()](#getBlob()) | [Blob](../base/blob.html) | Return the data inside this object as a blob. |\n| [getContent()](#getContent()) | `Byte[]` | Gets the raw binary content of an HTTP response. |\n| [getContentText()](#getContentText()) | `String` | Gets the content of an HTTP response encoded as a string. |\n| [getContentText(charset)](#getContentText(String)) | `String` | Returns the content of an HTTP response encoded as a string of the given charset. |\n| [getHeaders()](#getHeaders()) | `Object` | Returns an attribute/value map of headers for the HTTP response. |\n| [getResponseCode()](#getResponseCode()) | `Integer` | Get the HTTP status code (200 for OK, etc.) of an HTTP response. |\n\nDetailed documentation \n\n`get``All``Headers()` \nReturns an attribute/value map of headers for the HTTP response, with headers that have\nmultiple values returned as arrays.\n\n```javascript\n// The code below logs the HTTP headers from the response\n// received when fetching the Google home page.\nconst response = UrlFetchApp.fetch('http://www.google.com/');\nLogger.log(response.getAllHeaders());\n```\n\nReturn\n\n\n`Object` --- a JavaScript key/value map of HTTP headers\n\n*** ** * ** ***\n\n`get``As(contentType)` \nReturn the data inside this object as a blob converted to the specified content type. This\nmethod adds the appropriate extension to the filename---for example, \"myfile.pdf\". However, it\nassumes that the part of the filename that follows the last period (if any) is an existing\nextension that should be replaced. Consequently, \"ShoppingList.12.25.2014\" becomes\n\"ShoppingList.12.25.pdf\".\n\nTo view the daily quotas for conversions, see [Quotas for Google\nServices](https://developers.google.com/apps-script/guides/services/quotas). Newly created Google Workspace domains might be temporarily subject to stricter\nquotas.\n\nParameters\n\n| Name | Type | Description |\n|-----------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `content``Type` | `String` | The MIME type to convert to. For most blobs, `'application/pdf'` is the only valid option. For images in BMP, GIF, JPEG, or PNG format, any of `'image/bmp'`, `'image/gif'`, `'image/jpeg'`, or `'image/png'` are also valid. For a Google Docs document, `'text/markdown'` is also valid. |\n\nReturn\n\n\n[Blob](../base/blob.html) --- The data as a blob.\n\n*** ** * ** ***\n\n`get``Blob()` \nReturn the data inside this object as a blob.\n\nReturn\n\n\n[Blob](../base/blob.html) --- The data as a blob.\n\n*** ** * ** ***\n\n`get``Content()` \nGets the raw binary content of an HTTP response.\n\n```javascript\n// The code below logs the value of the first byte of the Google home page.\nconst response = UrlFetchApp.fetch('http://www.google.com/');\nLogger.log(response.getContent()[0]);\n```\n\nReturn\n\n\n`Byte[]` --- the content as a raw binary array\n\n*** ** * ** ***\n\n`get``Content``Text()` \nGets the content of an HTTP response encoded as a string.\n\n```javascript\n// The code below logs the HTML code of the Google home page.\nconst response = UrlFetchApp.fetch('http://www.google.com/');\nLogger.log(response.getContentText());\n```\n\nReturn\n\n\n`String` --- the content of the HTTP response, as a string\n\n*** ** * ** ***\n\n`get``Content``Text(charset)` \nReturns the content of an HTTP response encoded as a string of the given charset.\n\n```javascript\n// The code below logs the HTML code of the Google home page with the UTF-8\n// charset.\nconst response = UrlFetchApp.fetch('http://www.google.com/');\nLogger.log(response.getContentText('UTF-8'));\n```\n\nParameters\n\n| Name | Type | Description |\n|-----------|----------|-------------------------------------------------------------------------------------|\n| `charset` | `String` | a string representing the charset to be used for encoding the HTTP response content |\n\nReturn\n\n\n`String` --- the content of the HTTP response, encoded using the given charset\n\n*** ** * ** ***\n\n`get``Headers()` \nReturns an attribute/value map of headers for the HTTP response.\n\n```javascript\n// The code below logs the HTTP headers from the response\n// received when fetching the Google home page.\nconst response = UrlFetchApp.fetch('http://www.google.com/');\nLogger.log(response.getHeaders());\n```\n\nReturn\n\n\n`Object` --- a JavaScript key/value map of HTTP headers\n\n*** ** * ** ***\n\n`get``Response``Code()` \nGet the HTTP status code (200 for OK, etc.) of an HTTP response.\n\n```javascript\n// The code below logs the HTTP status code from the response received\n// when fetching the Google home page.\n// It should be 200 if the request succeeded.\nconst response = UrlFetchApp.fetch('http://www.google.com/');\nLogger.log(response.getResponseCode());\n```\n\nReturn\n\n\n`Integer` --- HTTP response code (e.g. 200 for OK)"]]