Questions tagged [http-request]
Use it for questions about HTTP requests, sending and receiving requests, status codes and more.
117
questions
1
vote
1
answer
680
views
How to handle the cache per user in REST Resource?
I have a requirement to expose a specific content type data via REST end point. Below is my code:
public function get() {
$current_user = $this->currentUser->id();
$user = $this->...
0
votes
0
answers
981
views
Guzzle POST HTTPS requests return 403 Forbidden only when called inside PHPUnit tests
On one side I have a remote Drupal 8 (8.8.1) served via HTTPS which has the following endpoint:
MODULENAME.get_notify:
path: 'MODULENAME/get-notify'
defaults:
_controller: '\Drupal\MODULENAME\...
1
vote
0
answers
702
views
cant read current user in middleware
i am relatively new to drupal . thus i am trying to make an sso system work . i have this parent domain "domain.com" and the drupal site is running on sub.domain.com . i can read the cookies and all ....
0
votes
1
answer
1k
views
How can I return a JSON response from an internal function ? (not the main callback)
I have a callback that is running for a specific post request.
I am returning a certain JSON response at the end of it.
What if I want to catch errors inside one of the functions that are ran in that ...
0
votes
1
answer
1k
views
How do I handle an incoming POST request in a module?
I am really new to Drupal but I have to do a project using it and I was just wondering how to handle an incoming POST request in a module:
I am creating a module that will get incoming data from a ...
0
votes
0
answers
322
views
How to Resolve CORB Issue using Drupal Docker Container
I'm running the latest version of the Drupal docker container.
I'm trying to make a GET API call via Javascript and I'm receiving back CORB (cross-origin-read-blocking) errors in the Console when ...
1
vote
1
answer
852
views
How to get the uncached version of request headers?
We need to programmatically get the request headers using the mymodule_preprocess_page hook. To do this we tried the following, however, because we have CDN, Varnish, and Drupal Cache all enabled, the ...
0
votes
0
answers
51
views
Help needed with ajax request from Jquery to callback function
I create the callback url 'swish_payment/request' in my hook_menu() function:
function swish_payments_menu(){
$items['swish_payment/request'] = array(
'type' => MENU_CALLBACK,
...
2
votes
2
answers
820
views
Hide title if 404 error
I have a custom 404 error page, and I just want a quick module that hides the 404 page title, if the user arrives at a 404 error.
I've found a D7 function that looks like it would work, checking for ...
1
vote
2
answers
406
views
WSOD while sending headers, probably Cache-related
I have a very strange problem with a fresh Drupal install: On some pages, I receive a WSOD with ERR_EMPTY_RESPONSE:
It happens for instance when on admin/config/development/performance I click Clear ...
1
vote
1
answer
109
views
Omega theme showing 404 on iPhone
I have a site on my local server which is served by Apache using virtual hosts. I am using an omega sub-theme. On the desktop everything works fine. I try to browse to the site via the iPhone by ...
2
votes
2
answers
1k
views
Top level directory files like readme.txt are served by apache
The content of the top-level server directory is publicly available by the web, e.g. files like example.com/readme.txt are readable.
Is it normal? How can i disable this?
(apache, ubuntu 12.04)
-1
votes
1
answer
1k
views
Drupal not able to make any outgoing HTTP requests
So, my drupal setup is on a NAS architecture. It's a portal for a college department and is hosted on the campus NAS. This basically means that my web server has to connect through an internal proxy ...
3
votes
5
answers
11k
views
500 Internal Server Error
I changed my server and when I uploaded my site this error appeared:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
...
0
votes
1
answer
350
views
Access forbidden 403 to homepage but the rest of website working Drupal 7
I have Drupal 7 installed in localhost, with XAMPP, and it is a replica of a complete working site. I think I have configured everything ok as I can see all the site working nice, with its friendly ...
2
votes
1
answer
91
views
Need to alter response headers for error pages
We have Cloudflare sitting in front of our Drupal sites - and in order to take advantage of their "AlwaysOnline" feature - we need to alter the response code sent in the event of an error.
I want to ...
5
votes
1
answer
1k
views
What should I set my Content-Security-Policy to?
I'm using Drupal 8, and I currently use
Header always set Content-Security-Policy "default-src 'self'; nosniff"
However, this causes bugs, such as Google Analytics not working and the textbox ...
0
votes
1
answer
330
views
The web service endpoint returned a "HTTP/1.1 403 Forbidden" response
There are 12 or so similar questions but not drupal related.
Here is my site on a digitalocean droplet: http://104.236.27.226/
It is apache2 on ubuntu16 php7.
I am using: 000-default.conf:
...
0
votes
1
answer
26
views
500 error on one page in entire site only showing error "You are here" instead of administration content
this error seems to only affect one page in on the website, and nowhere else.
Here is what it looks like:
The watchdog reports do not show the issue, and I believe it to be a permission error or ...
0
votes
1
answer
1k
views
Removing specific HTTP response header
I am trying to remove specific HTTP response header from my site.
The header looks like this:
Link: <https://example.com>; rel="canonical",<https://example.com>; rel="shortlink"
So far ...
0
votes
1
answer
153
views
Securing Admin on separate port
I am attempting to secure the admin pages (/admin/*) and login page (/user/login) to port 8443. I have successfully done that with the following in apache 2.4:
<VirtualHost _default_:443>
...
2
votes
1
answer
445
views
How to add certificate to drupal_http_request()?
I am currently setting up a payment method in my Drupal 7 site and following the API documentation for the service I could use this cURL command for testing purposes:
$ curl -s -S -i --cert
./...
2
votes
0
answers
232
views
How do I access data nested within JSON in a Guzzle service description response model? [closed]
I'm trying to pull some data into Drupal from a service, via Guzzle. I've got several clients like this working, but the data returned by this service is structured a bit differently:
{
pager: [ ],
...
2
votes
2
answers
892
views
Returning alternate HTTP codes for unpublished content
Sometimes when nodes are unpublished, they are not meant to be taken live again.
Under those circumstances, I would like to return a 410 Gone status, instead of the default 403 Forbidden.
...
0
votes
1
answer
229
views
Get data from remote REST API (read only)
We use a remote service (not Drupal) to publish press releases and to show those releases in a remote newsroom.
This remote service offers an API so we should be able to fetch and show the newsroom ...
0
votes
0
answers
135
views
drupal_http_request as authenticated user during cron
I have a rule set up that runs during cron. Part of that rule is an action that is supposed to save a PDF (via Entity Print which only authenticated users can access) to my server. It works fine when ...
3
votes
1
answer
342
views
How do I return 500 for fatal errors?
When I am trying to access Drupal and the database is down, it will return a 500 error. However, when I try to access Drupal when Redis is down, it says:
Additional uncaught exception thrown while ...
3
votes
0
answers
328
views
Site is down due to MySQL error but it returns 200/OK
A site I help administer was showing a uncaught exception page.
Additional uncaught exception thrown while handling exception.
PDOException: SQLSTATE[HY000] [2002] Can't connect to local MySQL
...
1
vote
1
answer
600
views
Handling access denied result
In Drupal 8, what is the correct way of returning access denied to a user (outside of access requirement on a controller)?
I'd say it is to throw an AccessDeniedHttpException most of the time, but I ...
26
votes
3
answers
18k
views
How to check if the current page is a 404 error from a module/template?
How to check, in D7, if the current page is returning a 404 error from a module/template?
-1
votes
1
answer
415
views
How to force 403 or 404 on specific route
I have made a custom form to create nodes for a specific content type. Due to that, I want to throw a 403 or 404 on the admin page that creates new node. The route I mean is 'node/add/'.
I guess in ...
0
votes
1
answer
32
views
POST from external source
I have external site that needs to POST my drupal site (it basically shares data). I need to take the POST data parse it and create a node from it. Is this possible? I have created a PHP file ...
0
votes
2
answers
749
views
Drupal 7 - Cors
I'm trying to get a hang of the CORS requests.
I'm logged in at the website, this is done manually from the website.
Now I'm trying to fetch my own user data from another website.
I have the "fetch ...
6
votes
3
answers
8k
views
How to get remote webpage content with drupal http request?
Would love to see some examples on getting remote webpage content with drupal http request. I have plenty of examples easily with Google with curl, but yet to find one with this drupal function.
Also,...
0
votes
1
answer
2k
views
Problem with cURL
I've run into a strange issue.
I have a few simple lines CURL code for calling an api service. This code runs perfectly fine when running outisde of Drupal (in php file in browser and cli), but when ...
3
votes
1
answer
3k
views
How to post xml data in drupal_http_request? I have curl code of it
This is following curl code
$ch = curl_init(); //initiate the curl session
curl_setopt($ch, CURLOPT_URL, $url); //set to url to post to
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // ...
0
votes
1
answer
53
views
How to remove any data "http_proxy" module added or changed?
I have a serious problem with a broken XML-Feed, that occurred after I installed http_proxy module. I have uninstalled the module, cleared the cache several times and even truncated the cache tables ...
0
votes
1
answer
4k
views
An AJAX HTTP error ocurred. HTTP Result Code: 500 (while trying to rebuild content access perms)
I have installed a module that ask me everytime to rebuild content Access Permissions, but every time I try to do it, it shows me an error I do not have idea why is it happening. Please help
An AJAX ...
3
votes
1
answer
5k
views
8 - Alter HTTP Response Headers
I noticed this question, which discusses various ways to alter HTTP Response Headers.
Where would I be able to execute:
$response->headers->remove('X-Frame-Options');
I attempted to place ...
2
votes
1
answer
2k
views
How do I pass parameters as JSON format to the HTTP client request?
How can I pass parameters to the http client get request in json format:
$clientFactory = \Drupal::service('http_client_factory');
$client = $clientFactory->fromOptions(['verify' => FALSE]);
$...
1
vote
1
answer
983
views
drupal_http_request with proxy
I'm working on proxy based machine where I've configured my proxy settings at settings.php and its working fine.
When I'm trying to access a URL the data is getting displayed perfectly, for instance, ...
0
votes
2
answers
1k
views
HTTP error 500 when backup entire site
Using Backup and Migrate module on a D7 site
separate backups (data / files) give no problem (backup to nodesquirrel AND download)
but backup entire site (data + files) generates "http error 500" (...
1
vote
1
answer
287
views
Jquery Ajax to Drupal to External site, reading response
I have a drupal site.
There is a page (page 1) with a form that gathers user info and submits it via AJAX to a Drupal Module page.
The AJAX format is jquery
var responseTarget = '/site/module/...
1
vote
1
answer
23
views
Validation Users Issues
I have my fresh web site up and running. My first test is to try the functionality of creating a new user. I tested added myself (no, not my admin account -- a different one with a different email ...
0
votes
0
answers
136
views
How to get HTTPS url to work with Drupal Iframe Module?
I want to get HTTPS urls working as iframes. Now only http URL's work.
https://www.drupal.org/project/iframe
Is there a way to do that?
5
votes
2
answers
18k
views
How to use drupal_http_request for send data?
I need some help in sending data in an array (POST) to a webservice (REST). I need some examples in how to use the function drupal_http_request().
Now, I'm using cURL with PHP but I need to replace ...
0
votes
1
answer
3k
views
Problem with SSL certificate [closed]
I just enable SSL certificate for my domain.
I added that in my .htaccess file:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^domainname\.com*
RewriteRule ^(.*)$ https://www.domainname.com/$...
1
vote
1
answer
1k
views
404 page not found error even though the page exists
On my Drupal 7 website, I'm getting a 404 page not found error on the front page: http://mydomain.com even though I can view the page just fine. Google Webmaster tools wouldn't validate my site; w3 ...
1
vote
0
answers
2k
views
How to set GET param to current Request?
I created a service and it works as well.
A piece of my code from "event_subscriber":
public function addRequestAddValue(GetResponseEvent $event) {
$request = $event->getRequest();
$request-&...
0
votes
1
answer
511
views
problem with drupal_http_build_query output
am using drupal_http_build_query and have part of my code as follows:
$or = db_or();
$or->condition('cid',$fField1);
$or->condition('cid',$fField2);
$or->condition('cid',$fField3);
$or->...