[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eApp Engine applications utilize the URL Fetch service to make both HTTP and HTTPS requests, with the protocol being determined by the target URL.\u003c/p\u003e\n"],["\u003cp\u003eThe URL Fetch service supports various HTTP methods including GET, POST, PUT, HEAD, DELETE, and PATCH, and allows for the inclusion of HTTP headers and payloads.\u003c/p\u003e\n"],["\u003cp\u003eThere are certain HTTP headers that the application cannot modify for security reasons, such as Content-Length, Host, and X-Appengine-Inbound-Appid, which are managed by App Engine.\u003c/p\u003e\n"],["\u003cp\u003eRequests have a default timeout of 10 seconds, with a maximum deadline of 60 seconds for HTTP(S) requests, Task Queue, and cron job handlers.\u003c/p\u003e\n"],["\u003cp\u003eThe service has several limits to take into account, such as request size (10 megabytes), response size (32 megabytes), and request header size (16KB), along with the maximum deadlines mentioned.\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/php/issue-requests).\n\n\n| This API is supported for first-generation runtimes and can be used when [upgrading to corresponding second-generation runtimes](/appengine/docs/standard/\n| php-gen2\n|\n| /services/access). If you are updating to the App Engine PHP 7/8 runtime, refer to the [migration guide](/appengine/migration-center/standard/migrate-to-second-gen/php-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. The PHP language provides several functions for making remote HTTP requests. These are implemented in different ways in App Engine, and are subject to different quotas and costs. For more information on the different types, see [Issuing HTTP(S) Requests](/appengine/docs/legacy/standard/php/issue-requests).\n\n\u003cbr /\u003e\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\nThe maximum deadline is 60 seconds for HTTP(S) requests and 60 seconds\nfor Task Queue and cron job requests.\n\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\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/php/issue-requests#issuing_a_request_to_another_app_engine_app)\nand instead return a redirect response to the application.\n\n\nIf the incoming response exceeds the maximum response size\nlimit, the URL Fetch service automatically truncates the response.\nSee the [Quotas and limits](#quotas_and_limits_for_url_fetch) section for details.\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/php/issue-requests)."]]