[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-04 UTC。"],[[["\u003cp\u003eApp Engine applications utilize the URL Fetch service to make both HTTP and HTTPS requests, and this service is also accessible directly through the \u003ccode\u003eurlfetch\u003c/code\u003e library.\u003c/p\u003e\n"],["\u003cp\u003eThe URL Fetch service can be disabled when using Serverless VPC Access or the Sockets API to prevent request failures, allowing the standard Python library to handle HTTP requests, and the \u003ccode\u003eurlfetch\u003c/code\u003e library can be selectively used when specific URL Fetch features are needed.\u003c/p\u003e\n"],["\u003cp\u003eThe service supports various HTTP methods like GET, POST, PUT, HEAD, DELETE, and PATCH, with the ability to include custom HTTP headers and a payload for certain methods.\u003c/p\u003e\n"],["\u003cp\u003eWhen making requests through the URL Fetch service, certain headers such as \u003ccode\u003eContent-Length\u003c/code\u003e, \u003ccode\u003eHost\u003c/code\u003e, and \u003ccode\u003eX-Appengine-Inbound-Appid\u003c/code\u003e cannot be modified by the application and are managed by App Engine.\u003c/p\u003e\n"],["\u003cp\u003eThe URL Fetch service has limitations on request and response sizes, specifically, requests are limited to 10 megabytes, request header size to 16KB, and response size to 32 megabytes, with the option to truncate responses rather than raise an exception.\u003c/p\u003e\n"]]],[],null,["# URL Fetch for legacy bundled services\n\nThis page describes how App Engine applications\nuse the URL Fetch service to\n\nissue HTTP and HTTPS requests and receive responses.\nTo see code samples demonstrating how to issue HTTP and HTTPS requests from your\nApp Engine application, see\n[Issuing HTTP(S) Requests](/appengine/docs/legacy/standard/python/issue-requests).\n\n\nIf you have\n[set up Serverless VPC Access](/appengine/docs/legacy/standard/python/connecting-vpc)\nor if you use the [Sockets API](/appengine/docs/legacy/standard/python/sockets), you\nneed to [stop URL Fetch from handling requests](/appengine/docs/legacy/standard/python/sockets#making_httplib_use_sockets).\nURL Fetch causes requests to your VPC network or to the\nSockets API to fail. After you disable URL Fetch, the standard Python library\nwill handle HTTP requests. If you need the features provided by URL Fetch\nfor specific requests, you can use the `urlfetch` library directly for those\nspecific requests.\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| python3\n|\n| /services/access). If you are updating to the App Engine Python 3 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/python-differences) to learn about your migration options for legacy bundled services.\n\nRequests\n--------\n\nApp Engine uses the URL Fetch service to issue outbound requests. In Python, you can use the `httplib`, `urllib`, and `urllib2` libraries to make HTTP requests; in an App Engine application, each library will perform these requests by using the URL Fetch service. You can also use the [`urlfetch`](/appengine/docs/legacy/standard/python/refdocs/google.appengine.api.urlfetch) library directly.\n\n### Request protocols\n\nAn application can fetch a URL using either HTTP or HTTPS. The protocol that\nshould be used is inferred by looking at the protocol in the target URL.\n\nThe URL to be fetched can use any port number in the following\nranges:\n\n- `80`-`90`\n- `440`-`450`\n- `1024`-`65535`.\n\nIf the port is not mentioned in the URL, the port is implied by the\nprotocol. HTTP requests occur on port `80`, and HTTPS requests occur\non port `443`.\n\n### Request methods\n\nIf you issue requests through the URL Fetch service, you can use any of the\nfollowing HTTP methods:\n\n- `GET`\n- `POST`\n- `PUT`\n- `HEAD`\n- `DELETE`\n- `PATCH`\n\nA request can include HTTP headers and, for `POST`, `PUT`, and `PATCH`\nrequests, a payload.\n\n### Request proxying\n\nNote that the URL Fetch service uses an HTTP/1.1 compliant proxy to fetch the result.\n\nTo prevent an application from causing an endless recursion of requests, a\nrequest handler is not allowed to fetch its own URL. It is still\npossible to cause an endless recursion with other means, so\nexercise caution if your application can be made to fetch requests for\nURLs supplied by the user.\n\n### Request headers\n\nYour application can set HTTP headers for the outgoing request.\n\nWhen sending an HTTP `POST` request, if a `Content-Type` header is\nnot set explicitly, the header is set to `x-www-form-urlencoded`.\nThis is the content type used by web forms.\n\nFor security reasons, the following headers cannot be modified\nby the application:\n\n- `Content-Length`\n- `Host`\n- `Vary`\n- `Via`\n- `X-Appengine-Inbound-Appid`\n- `X-Forwarded-For`\n- `X-ProxyUser-IP`\n\nThese headers are set to accurate values by App Engine as\nappropriate. For example, App Engine calculates the\n`Content-Length` header from the request data and adds it to\nthe request prior to sending.\n\nThe following headers indicate the application ID of the requesting app:\n\n- `User-Agent`. This header can be modified, but App Engine will append an identifier string to allow servers to identify App Engine requests. The appended string has the format `\"AppEngine-Google; (+http://code.google.com/appengine; appid: APPID)\"`, where `APPID` is your app's identifier.\n- `X-Appengine-Inbound-Appid`. This header cannot be modified, and is added automatically if the request is sent via the URL Fetch service when the follow redirects parameter is set to `False`.\n\n### Request timeouts\n\nYou can set a deadline, or timeout, for a request. By default, the\ntimeout for a request is 10 seconds.\n\n\nYou can send synchronous requests and asynchronous requests. The following\nbehavior applies to the URL Fetch API:\n\n- *Synchronous requests*: The fetch call waits until the remote host returns a result, and then returns control to the application. If the maximum wait time for the fetch call is exceeded, the call raises an exception.\n- *Asynchronous requests*: The URL Fetch service starts the request, then returns immediately with an object. The application can perform other tasks while the URL is being fetched. When the application needs the results, it calls a method on the object, which waits for the request to finish if necessary, then returns the result. If any URL Fetch requests are pending when the request handler exits, the application server waits for all remaining requests to either return or reach their deadline before returning a response to the user.\n\nSecure connections and HTTPS\n----------------------------\n\nYour application can fetch a URL securely by using HTTPS to connect to\nsecure servers. Request and response data are transmitted over the\nnetwork in encrypted form.\n\nBy default, the URL Fetch proxy validates the host it contacts. This behavior\nallows the API to detect man-in-the-middle attacks\nbetween App Engine and the remote host when using HTTPS.\n| **Note:** The `urllib` module doesn't provide methods to validate hosts.\n\nResponses\n---------\n\nIf you use the URL Fetch API, note that the URL Fetch service returns all\nresponse data, including the response, code, headers, and body.\n\nBy default, if the URL Fetch service receives a response with a\nredirect code, the service will follow the redirect. The service will\nfollow up to five redirect responses, then return the final resource.\n\nYou can\n[instruct the URL Fetch service to not follow redirects](/appengine/docs/legacy/standard/python/issue-requests#issuing_a_request_to_another_app_engine_app)\nand instead return a redirect response to the application.\n\n\n| **Note:** The URL Fetch API imposes response\n| size limits. If the incoming\n| response exceeds the maximum response size\n| limit, the URL Fetch service raises an exception. See the\n| [Quotas and limits](#quotas_and_limits_for_url_fetch) section for details.\n|\n| You can instruct the URL Fetch API to truncate the response instead of\n| raising an exception. If you use\n| the `urllib`, `urllib2`, or `httplib`\n| libraries to fetch URLs, the response is always truncated, and no\n| exception is raised.\n\nUsing URL Fetch on the development server\n-----------------------------------------\n\nWhen your application is running on the App Engine development server on your\ncomputer, calls to the URL Fetch service are handled locally. The\ndevelopment server fetches URLs by contacting remote hosts directly\nfrom your computer, using whatever network configuration your computer\nis using to access the Internet.\n\nWhen testing the features of your application that fetch URLs, make sure\nthat your computer can access the remote hosts.\n\nQuotas and limits for URL Fetch\n-------------------------------\n\nFor information about URL Fetch service quotas, see\n[Quotas](/appengine/docs/quotas#UrlFetch). To see the current quota usage of\nyour application, go to the Quota Details page in the\nGoogle Cloud console.\n\n[Go to the Quota Details page](https://console.cloud.google.com/appengine/quotadetails)\n\nIn addition, the following limits apply to the use of the\nURL Fetch service:\n\nWhat's next\n-----------\n\nRun code samples and get guidance on how to issue requests from your\napplication in [Issuing HTTP(S) Requests](/appengine/docs/legacy/standard/python/issue-requests)."]]